Riley
0
Q:

c++ class method example

class Object {
public:
	int var;
	void setVar(int n) {
		var = n;
	}
	int getNum() {
		return var;
	}
};

int main() {
	Object obj;
	obj.setVar(13);
	std::cout << obj.getNum() << std::endl;
	return 0;
}
3
class Name {
  private:
  	int data;
  
  public:
  
    // Constructor
  	Name() {
		// Code      
    }
  	int id;
  	void fun1(int a) {
        // Some instructions here 
    }
 	 
}
0

New to Communities?

Join the community