15,906,645 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by the_beginner (Top 42 by date)
the_beginner
6-Jul-17 2:41am
View
thanks for reply, will keep in mind
the_beginner
6-Jul-17 2:00am
View
ok Sorry, let me break it down:
1. Take n righmost bits of Y and place them at location P.
a) ~0<<n --- > to make all bits 1 except rightmost n bits
b) ~(~0<<n) --> get it reverse
c) y & ~(~0<<n) ---> Make all bits except rightmost n bits to 0
d) (y & ~(~0<<n)) << (p-1) --> Move n rightmost bits of Y to position P
2. Now to make n bits of x from position P to 0
a. Same steps a-b from 1
b. ~((~(~0<<n)) << (p-1)) ---> Make n bits from position P as 0 and rest will be 1.
c. x & ~((~(~0<<n)) << (p-1)) --> Make n bits from position P as 0 in x.
3. Finally 'or' between final results from step 1 and 2. to get desired result.
(x & ~((~(~0<<n)) << (p-1))) | ((y & ~(~0<<n)) << (p-1))
the_beginner
6-Jul-17 0:48am
View
This is what i came up with, any improvement which can be done to it:
unsigned setbits(unsigned x, int p, int n, unsigned y)
{
return((x & ~((~(~0<<n))<<(p-1)))| ((y & ~(~0<<n))<<(p-1)));
}
the_beginner
4-Jul-17 8:23am
View
Thanks for reply. So when I am entering "abaad", after hitting Enter, c is taking values one by one from "abaad" and then going through while loop ?
the_beginner
21-Jun-17 4:26am
View
thanks, got it
the_beginner
21-Jun-17 2:47am
View
thanks
the_beginner
21-Jun-17 2:45am
View
Thanks for reply.
So there is no difference between char *str and char str[] except for that char *str is constant
the_beginner
21-Jun-17 2:25am
View
Thanks for reply
the_beginner
21-Jun-17 2:25am
View
Thanks for advice
the_beginner
21-Jun-17 2:15am
View
Thanks a lot, i will keep the comment for variable names in notice.
the_beginner
22-Oct-15 7:10am
View
So except for initializing values to zero does it serve any other purpose
the_beginner
6-Oct-15 4:22am
View
Thanks
the_beginner
6-Oct-15 4:20am
View
||=== Build: Debug in Learning-1 (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function `ZN4BaseC2Ev':|
main.cpp|13|undefined reference to `vtable for Base'|
obj\Debug\main.o||In function `ZN4BaseD2Ev':|
main.cpp|16|undefined reference to `vtable for Base'|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
here line 13 is Base constructor and line 16 is Base Destructor
the_beginner
20-Sep-15 6:33am
View
Thanks sir, got the troubling mistake (used temp instead of temp1 :P)
the_beginner
16-Sep-15 8:20am
View
Thanks a lot, finally it worked now I am declaring pointers as NULL during declaration and assigning values only after getting it in constructors. :D :D
the_beginner
16-Sep-15 8:20am
View
Thanks a lot, finally it worked now I am declaring pointers as NULL during declaration and assigning values only after getting it in constructors. :D :D
the_beginner
16-Sep-15 7:49am
View
no thats what i was saying if i do this
Department dp;
cin >> dp;
cout <<dp;
it won't crash ot works totally fine
the_beginner
16-Sep-15 7:39am
View
In case of Department class object either with or without deleting pointer to Student class it works fine, only in college class object all hell break loose
the_beginner
16-Sep-15 7:33am
View
Can anyone please help me out here and give a working code just so that I can make multiple Department class object data members of College class according to user input. As code is already there u just have to tweak the pointer to Department class declaration. It would be a great help .
the_beginner
16-Sep-15 7:29am
View
Its not working with this change too :(
the_beginner
16-Sep-15 7:14am
View
Sir, thanks for ur reply,
could u give me a sample code to initialize multiple objects of department class form college class according to user input because I am not able to figure it out :D
the_beginner
16-Sep-15 7:14am
View
Sir, thanks for ur reply,
could u give me a sample code to initialize multiple objects of department class form college class according to user input because I am not able to figure it out :D
the_beginner
16-Sep-15 6:55am
View
But with this method i will be able to create one object only , however i want it to be user input
the_beginner
16-Sep-15 4:35am
View
yes
the_beginner
16-Sep-15 4:14am
View
Then maybe something to do with IDE, i am using codeblocks
the_beginner
14-Sep-15 4:44am
View
thanks
the_beginner
11-Sep-15 2:59am
View
Down-scroll the question , they are in main()
the_beginner
7-Sep-15 8:44am
View
Thanks, thats a lot of content..
the_beginner
7-Sep-15 8:09am
View
i was looking for linked list, stack, queue, tree and graphs actually
the_beginner
7-Sep-15 6:58am
View
thanks
the_beginner
7-Sep-15 6:57am
View
thanks, I just want to ask as I am new to coding, generally in case of declaring array of objects do we need to initialize them in constructor or not ?
the_beginner
7-Sep-15 5:35am
View
It was a error in my question i have corrected it but if u see 2nd line in error, its because of Department and student,
the_beginner
3-Sep-15 8:56am
View
thanks it worked, but i am not using '=' in main code than how its affecting, also if same code is ran with
A( const A &a) //copy constructor
{
m_aptr=a.m_aptr;
}
it wrks fine how? , it would be great if u can answer.
the_beginner
3-Sep-15 6:57am
View
No error , it just show stop working, also problem is due to
*this=a in copy-constructor, if I replace that line with line under it (which is commented out), program runs successfully
the_beginner
1-Sep-15 1:03am
View
Thanks
the_beginner
27-Aug-15 7:10am
View
It will fail miserably :P , try on 1 to 9
prime no: 1,2,3,5,7
prime mult.= 210 , not divisible by 8 or 9 :P
the_beginner
27-Aug-15 6:11am
View
Also any comment or suggestion on coding will also be very appreciated, I am trying to learn C++
the_beginner
26-Aug-15 3:00am
View
Thanks, looks like my username won't be changing for quite a more time :P
the_beginner
24-Aug-15 7:23am
View
Thanks Richard sir.
the_beginner
24-Aug-15 7:15am
View
Thanks it worked, but just a small query why code worked when using cin instead of getline.
Iam using delete[] names; to release memory at the end of code
the_beginner
24-Aug-15 6:55am
View
thanks for ur answer.
but names[i] = new string; is giving compile time error:Invalid conversion from string* to char
By the way how come this code works if i use
cin >> names[i] instead of getline(cin,name) (but i can't enter names with spaces)
the_beginner
19-Aug-15 2:19am
View
Thanks
Show More