|
-
May 25th, 2008, 01:12 PM
#1
how much of C should I learn in C++?
Hello guys,
I read some articles on the net about some of the questions asked at job interviews.
I saw that many deal with the concepts that I'm not ware of, such as malloc and free.
The C++ book I've read so far did not mention them
and from what I gather, these are considered 'C' ways.
I also read Stroustrup's comment on how it is NOT necessary to know C in order to learn C++. But being here at the forum and doing some readings led me to believe I need to know C if I want to get a job as C++ programmer.
my question is how far back(or how deep) should I go in C ways of doing things?
This is a big concern for me because I feel like I do not have enough time to learn C and C++ at this point.
Thanks.
-
May 25th, 2008, 02:13 PM
#2
Re: how much of C should I learn in C++?
I think it's helpful to know a fair bit of C. Not so much for writing C++, as just to have a handle on the general concepts.
In the case of malloc/free, they're essentially the same as new/delete except that they have no concept of type. You allocate enough space for the type you want by using the sizeof() operator, and then just cast the memory to that type; it isn't initialized by a constructor as it would be with new.
-
May 25th, 2008, 04:10 PM
#3
Re: how much of C should I learn in C++?
Like Lindley said malloc/free is more like new/delete.
Details....
Heap memory is allocated using the new command followed by the type of object to allocate. For example, the following allocates a double variable off the heap.
Code:
double* child(void)
{
double* pdLocalVariable = new double;
return pdLocalVariable;
}
Although the variable pdLocalVariable goes out of scope when the function child() returns, the memory to which pdLocalVariable refers does not. A memory location returned by new does not go out of scope until it is explicitly returned to the heap using a delete command.
You should get a C++ job with that word for word. LOL.
-
May 25th, 2008, 04:29 PM
#4
Re: how much of C should I learn in C++?
JUST learn C++. Period. End of Discussion.
There is simply no poiont in learning things which are somewhere between inappropriat, wrong and plain illegal.
Once you have a good solid grasp on what is RIGHT to do in C++. Then start looking at other languages (such as "C") to see how they compare.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
May 25th, 2008, 05:02 PM
#5
Re: how much of C should I learn in C++?
 Originally Posted by TheCPUWizard
JUST learn C++. Period. End of Discussion.
Just right. At this stage, you should concentrate on C++.
Actually the C is useful in some situations where you deal with some old code. There you generally find the C-specific functions and macros. That's why, in the interviews they asked for C-specifics. In my opinion, one should tell them (the interviewers) that every task can be obtained through C++ and there is no need to learn C. If any need arises during job (for reasons mentioned above), it will be simpler to deal with C-specific code by just referring the C-documentation.
Well, this is my opinion. May be interviewers have some other!!!
Thanks and best regards.
Anwar-ul-Haque
-
May 25th, 2008, 05:18 PM
#6
Re: how much of C should I learn in C++?
Thanks guys!
@anwar4849: I see. Just curious, were you asked such a question when you tried out for your job?
thanks!
Last edited by potatoCode; May 25th, 2008 at 05:39 PM.
-
May 25th, 2008, 05:37 PM
#7
Re: how much of C should I learn in C++?
 Originally Posted by potatoCode
@anwar4849: I see. Just curious, were you asked such a question when you tried out for your job?
Fortunate enough, I have not come up with such situation!!!
-
May 25th, 2008, 05:40 PM
#8
Re: how much of C should I learn in C++?
 Originally Posted by anwar4849
Fortunate enough, I have not come up with such situation!!!
haha thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|