Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does C have classes?

Tags:

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).

I want to ask wtf? Does C have classes? Or is there a misunderstanding or something?

EDIT: I've come back to the question after so many years and noticed some a*****es took time to remove 99% text from the question. Get a life, this is not 1984 yet.

like image 904
Vanilla Face Avatar asked Apr 25 '12 12:04

Vanilla Face


People also ask

Is C++ just C with classes?

The C++ language is derived from the C language. C++ is the name for the C programming language with added 'classes' functionality. That means that the basic C language architecture has been enhanced to allow object oriented programming. It uses the "++" operator that means increment.

Why there is no class in C?

No,C does not have any class as it is procedural language(i.e,function based language) not object oriented language . Only object oriented programming language have classes like c++,java etc.

Are C structures classes?

In C++, structs and classes are pretty much the same; the only difference is that where access modifiers (for member variables, methods, and base classes) in classes default to private, access modifiers in structs default to public.

Is C difficult to learn?

C is more difficult to learn than JavaScript, but it's a valuable skill to have because most programming languages are actually implemented in C. This is because C is a “machine-level” language. So learning it will teach you how a computer works and will actually make learning new languages in the future easier.


1 Answers

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.

like image 62
Stuart Golodetz Avatar answered Oct 20 '22 17:10

Stuart Golodetz