GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 18 of 258    Print  
Difference between "C structure" and "C++ structure".

  
Total Answers and Comments: 16 Last Update: July 16, 2008   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Piyush/Santosh
 
The defination of the structure in C is limited to within the module and cannot be initialized outside its scope. Where as in C++ you can initialize the objects anywhere within the boundaries of the project.

Above answer was rated as good by the following members:
password, manjunath_r121113
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
July 20, 2005 12:48:49   #1  
Piyush/Santosh        

RE: Difference between "C structure" and "C++ structure".
The defination of the structure in C is limited to within the module and cannot be initialized outside its scope. Where as in C++ you can initialize the objects anywhere within the boundaries of the project.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
July 23, 2005 01:35:35   #2  
Girish        

RE: Difference between "C structure" and "C++ structure".
The on more deference is in C++ structure can have methods(procedures) but C can note have methodes in structure
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
August 25, 2005 10:54:17   #3  
satish        

RE: Difference between "C structure" and "C++ structure".
By default C structure are Public whil C++ structure are private

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
December 31, 2005 07:20:23   #4  
prafull        

RE: Difference between "C structure" and "C++ structure".
c can have methods in structures dude..
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
February 26, 2006 13:44:03   #5  
Rohan Member Since: November 2005   Contribution: 11    

RE: Difference between "C structure" and "C++ structu...

C does not support Methods inside structure.

Reason :

╔═[■]═══════════════════════
║#include <stdio.h>
║#include <conio.h>

║struct temp
║{
║ int a;
║ get_data()
║ {

printf( Enter value of a : );
║ scanf( d &a);
║ }
║}T;

║void main()
║{
║ T.get_data();
║}

saved file as .c file
Error : Function May not be part of structure of Union
and same code will run if you save file as .cpp


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
March 27, 2006 05:54:49   #6  
Yashwant S pinge        

RE: Difference between "C structure" and "C++ structure".
Since bydefault C and C++ structure members are public.In C you can declare structure as struct A a;But not A a(which is possible in C++);
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
June 04, 2006 15:12:48   #7  
rajesh        

RE: Difference between "C structure" and "C++ structu...

I cant able understand your answer. Please tell what method difference in C and C++. Please explain briefly. Please Reply to my ID

By

RajeshKumar.J


 
Is this answer useful? Yes | No
June 26, 2006 11:41:52   #8  
Anupama        

RE: Difference between "C structure" and "C++ structu...

Mr Rohan

I actually tried saving the code you have given with extention .c and .cpp and it runs for both... So I dont understand how you are saying that methods are possible only in the case of structures of cpp... could you clarify my query?

Thank you


 
Is this answer useful? Yes | No
August 25, 2006 09:44:05   #9  
Siddharth Nimkar        

RE: Difference between "C structure" and "C++ structure".
Turbo C will allow you to run the above code with .c extension.But try running the code in Dev C++ (this is another IDE) this will give you error. I guess Dev C++ uses gcc
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
October 04, 2006 10:28:26   #10  
avishek        

RE: Difference between "C structure" and "C++ structure".
C++ structures are also by default public
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape