Hi, this is my first post and I need your help, I need examples of how to use methods in c, that are simple, for example do any math operation with the variables that are part of the class. And, if you can, compare the method of the class with a normal function of structure. Please help me.
digimouse
0
Newbie Poster
Recommended Answers
Jump to PostA simple class
class MyClass { public: MyClass() { x = 0; } int Add(int n) { this->x += n; } private: int x; };
A normal function outside a class might look like this:
struct MyStruct { int x; }; int sum(int n, …
All 4 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
LevyDee
2
Posting Whiz in Training
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
LevyDee
2
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.