asked 197k views
5 votes
Write c++ program that has object and class. which it's data member is function?​

asked
User LPL
by
8.2k points

1 Answer

3 votes

Answer:

#include <iostream>

using namespace std;

class MyClass {

public:

int data;

void myFunction();

};

void MyClass::myFunction() {

cout << "This is a function inside a class" << endl;

}

int main() {

MyClass obj;

obj.data = 10;

obj.myFunction();

return 0;

}

answered
User Mark DeLoura
by
8.5k points

No related questions found