I've been working a lot in c++ and now i have to write my assignment in C.
Can C use classes (like be able to create new data types with public and private members?) Or do i basically have to do everything using structures?
I've been working a lot in c++ and now i have to write my assignment in C.
Can C use classes (like be able to create new data types with public and private members?) Or do i basically have to do everything using structures?
No and yes.
C does not support classes; in fact, C++ was originally called C with Classes. Structs are available though.
The only difference in C++ between a class and a struct is its default visibility of its members anyway. Classes default to private, and structs default to public. Other than that, in C++, they're identical.
Quzah.
Hope is the first step on the road to disappointment.
In C, use structs as classes. When you want to make a member function, declare it as an independent function, and make it take an additional "this" pointer.
and instead of
doCode:SomeClass c; c.someMember(1, 2);
Code:struct SomeStruct c; someMember(&c, 1, 2);