GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Tech FAQs  >  OOPS

 Print  |  
Question:   Difference between "C structure" and "C++ structure".



February 02, 2006 13:44:03 #5
 Rohan Networking Expert  Member Since: November 2005    Total Comments: 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"

     

 

Back To Question