What is the difference between a method and an object?

Isn't this a method?

void Standard::print_results()

What denotes an object?? CONFUSED!

#include <iostream>

class type
{
   int data;
public:
   type(int initializer = 0) : data(initializer) {}
   void method()
   {
	  std::cout << "data = " << data << std::endl;
   }
};

int main()
{
   type object(42);
   object.method();
   return 0;
}

/* my output
data = 42
*/

What is the difference between a method and an object?

Isn't this a method?

void Standard::print_results()

What denotes an object?? CONFUSED!

In your example print_results is the method. You then define an object of type Standard in order to be able to use this method on that object.

Object is in simple a user-defined data-type.
Methods are different properties of an object.

for example:

char String[30]='DFDFGDFG";

The above definition shows that 'String' is an object of pre-definied data-type char.
And what about methods? Know if want to add two strings then will not use
str3=str1+str2 directly, but you use strcopy(str3,str1); strcat(str3,str2);

Therefore strcat() & strcopy() are the methods or properties.

,cgnmgfnf;f

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.