Okay, you may call me a noob but I'm realling confused.
My ex classmate paid me to write a program in C. She gave me the task and it said something like "blah blah blah make at least two classes, write at least one constructor and rewrite at least one method" it says that word by word.
And then I told her "this is C++ not C" she said "but we're learning C"
I ignored it and wrote the program in c++ and sent to her as I thought she didn't know what she was talking about. She said "it doesn't work on code blocks, and wtf is cout <<" and then she sent me a chunk of code that they write and instead of cout and cin there was printf and scanf. It had to be C. So, I rewrote the program with printf and scanf and she still says codeblocks throw errors (I still left classes as task demanded).
Does C have classes? Or is there a misunderstanding or something?
No, C doesn't have classes. That said, there are ways of simulating object-oriented programming in C - a quick Google search should yield some useful results.
A classic case of conflicting requirements, it seems :-)
The terminology of her requirements CLASS, CONSTRUCTOR, METHOD are all C++ terminology, while none of them is C terminology (the closest of which would arguably be STRUCT, INITIALIZATION, FUNCTION). Your friend is confusing something here. I doubt that her teacher is confusing something, though...
C does not have classes.
But one can approximate a class by using static globals as private class members, and static functions as private member functions. extern members as public. In this case an entire file could be viewed as a class.
Probably this is not what you want.
C does not have classes, but you can emulate it with structures and pointers to a function. C99 is a little bit (just a bit) based on C++, so it's easy to reproduce classes with C.
C does not have the formal construct of a class. You can produce modules with module-level data that by your own agreement you will not extern anywhere else, or static data, and write functions to get, set, and otherwise manipulate that data. You can even go to the point of using function pointers to manipulate similar data types as if they were in a class.
However, you won't be protected by class semantics or other rules by the C compiler, because the C compiler does not know about classes. However, structuring your data is quite powerful.
No, C has no classes per se, only C++ (which started out as "C with classes" back then...). But you can use the standard C library in C++ code, even if it is often not considered good practice (where C++ has its own, higher level constructs, e.g.
cout
vsprintf
).You can sort of emulate the behaviour of classes, inheritance and virtual functions in C too, but it's not worth the pain.
You should probably buy/get your ex classmate a C programming book :-)