By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 964 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

basic data types

P: n/a
Hi
Does compiler generates classes for basic data types also ?? or it is
just same as calling malloc
What is the difference bwt 1) ^ 2) ..

1 )
char * c = new char ( 4 ) ;
delete c ;

2 )
char * c = new char [ 4 ] ;
delete [] c ;

Can we use delete [] c in first examples .

thanks
Paras

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Paras Sharma" <pa******@cisco.com> wrote in message
news:3F**************@cisco.com...
Hi
Does compiler generates classes for basic data types also ?? or it is
just same as calling malloc
I think you mean does the compiler initialise built in types when calling
new. The answer is maybe. In your example 1 below, the allocated char is
initialised, in your example 2 the allocates chars are not inituialised.


What is the difference bwt 1) ^ 2) ..

1 )
char * c = new char ( 4 ) ;
delete c ;
This creates a single char and initialises it with the value 4

2 )
char * c = new char [ 4 ] ;
delete [] c ;

This creates 4 uninitialised chars.


Can we use delete [] c in first examples .
No.

thanks
Paras


john
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.