how can you make class like data structure in C?

India
June 26, 2007 11:22am CST
As we are using class in C++. class has many facility like doing overloading. friend function. inline functions. but id want to do with in C then what are the options available that with we can do any type of programming that will happen with C++.
4 responses
@genser (17)
• China
26 Jul 08
There are no class in C.In my opinion,you can use the .h file like class,and the function can name like xxx_xxx to differentiate them.
@mnsrwt123 (2057)
• India
1 Apr 08
well, if you wanted to do class in C then its impossible or you can say very difficult though, but you can use header files instead of class in C. Keep posting!!!
@good1030 (670)
• China
5 Jul 07
C++ is an object oriented programming, and one of the feature of object oriented programming is data hiding, that means you can only access the data in the private section by using the member function in the public section, so if we want to access the data by using a normal function, we need to make this function a friend function, this is why we need friend function. But in C, we can use any function to access the data in a structure, so we don't need friend function at all. C also can make make function overloading and inline function. for inline function, you just put a "inline" keyword in front of the function prototype and then write the function definition together with the function prototype. for function overloading, you can just define more than one functions all with the same function name, but with different signatures.
@federickp (607)
• India
26 Jun 07
hello friend, from your questions i have realised that you are novice to C and C++ programming. C is not an object oriented language,but C++ is. Never think of class,objects and all advantages object oriented style provides,because simply the C wasnt build to be object oriented. C offers other great things ,like simplicity of system level programming. C++ is nothing but C + object concepts. One more thing, you said that class has many facilities like overloading,friend function,inline functions..etc. Take note that its not the class which provides us all these. FOr example, we dont have friend functions in every object oriented language. These can be more appropiately called as the functionalities of object oriented programming. What a class offers is the binding of data (relevant data ) together with the functions accessing the data. Hope this has helped you.