+ 1

Can anyone explain class in c++ in a very simple way?

The class in c++ is always confusing me and I lose many challenges because of this class.

11th Jul 2017, 12:22 AM
kishore kumar
kishore kumar - avatar
3 Antworten
+ 3
A wise programmer told me classes are like lego bricks and 3D printers, give them an instruction and they will follow it when you call them.
11th Jul 2017, 1:50 AM
Complex
Complex - avatar
+ 2
A class is an abstraction of the thing someone wants to create. Like class "Animal", So a class does not mean anything, you would not know at which animal i'm referring at, unless I'm creating an object, of the class, where I would be specific, by filling the properties which at first have no value. Example: public class Animal { String name; public void eat (String food){ System.out.println("This animal eats "+food); } } // The entry point of any program public static main void (String [] args){ Animal tiger = new Tiger (); tiger.eat ("meat"); tiger.name = "Shere Kahn"; } Sorry thay I used java for explaining this :).
11th Jul 2017, 5:32 AM
Claudiu Stefan Haidu
Claudiu Stefan Haidu - avatar