Creating Classes and functions

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Creating Classes and functions

Post by Strong99 »

I have created an own class with functions, only when i call those functiosn it says

Code: Select all

d:\MMORPG\Code\Server\main.cpp(43): error C2352: 'RPG_calls::RPG_go: illegal call of non-static member function
In the header:

Code: Select all

class RPG_calls
{
public:
	void RPG_go(char*calls)
};
In the .cpp:

Code: Select all

void RPG_calls::RPG_go(char*calls)
{

}
Aukecomps
Posts: 19
Joined: Wed Apr 05, 2006 7:53 pm

Post by Aukecomps »

...
Last edited by Aukecomps on Sun Dec 06, 2015 1:18 am, edited 1 time in total.
Ced666
Posts: 86
Joined: Fri Jan 13, 2006 10:29 am
Location: Belgium

Post by Ced666 »

It's because you are calling a function of a class directly. You first need to declare an instance of the class and work with that.

Code: Select all

RPG_calls MyClass;
MyClass.RPG_go("Test");
And by the way, what are you trying to do here ?
I strongly suggest you read some books about programation because this is really the basics of programing.

And, honnestly, if I were you, I would first start with simple programs ! Like a pong or a tetris (and you will already see that it is REALLY extremly difficult for a beginner). A MMORPG is something that takes several years for a team of professionals to develop. So, you, as a beginner and amateur, don't even imagine the time it will take. Do you have enough time ? One or two centuries ? Hope that medicine will do some progress soon :wink:
I don't want to be mean or to destroy your hope, but MMORPG are for now the more complex games to develop. And, if you even don't know how to use a class, that's completely absurd. Programming is also something that takes time (it's like learning music or sport), it is difficult and long.
This is just an advice, don't take it wrong.
Aukecomps
Posts: 19
Joined: Wed Apr 05, 2006 7:53 pm

Post by Aukecomps »

...
Last edited by Aukecomps on Sun Dec 06, 2015 1:18 am, edited 1 time in total.
Ced666
Posts: 86
Joined: Fri Jan 13, 2006 10:29 am
Location: Belgium

Post by Ced666 »

but is it too less to be able to program something difficult?
Are you 'fluent' with the concepts of OOP (oriented-object programming), things like polymorphism, design patterns,... ? I believe that all these things are required whenever you want to do something more elaborate than a pong (and even in a pong, it is very very usefull).

A lot of people look at MMORPG like a game in which you can move a character and fight and that's it, but they don't sey what's beyond this. It looks easy to do but it's not at all. Did you even think of how pathfinding works ? How the AI is managed? All these things that needs to be implemented and that are not so easy to do (specifically for AI).
It requires not only an perfect knowledge of what you call the 'grammar manual' but a analytical mind in how you are gonna solve complex algorithm and how to solve 'architectural' problems (how you are gonna arrange your classes).
I have more or less 5 years of programming experience (as professional) and I still find that I have a lot of things to learn and I won't be able do to a complete MMORP being the only programmer.
Aukecomps
Posts: 19
Joined: Wed Apr 05, 2006 7:53 pm

Post by Aukecomps »

...
Last edited by Aukecomps on Sun Dec 06, 2015 1:18 am, edited 1 time in total.
Xaron
Posts: 310
Joined: Sun Oct 16, 2005 7:39 am
Location: Germany
Contact:

Post by Xaron »

Ced666 is right. strong99, I'm not sure anymore, that a MMORPG is a good starting project. ;)

Regarding your compiler error: You could make your RPG_go method static:

In your header declare:

Code: Select all

public:
  static void RPG_go(char* calls);
But this should only be done if it's really necessary. Sometimes this is useful. But don't wonder, you can't deal with member variables then, cause of the missing instance of the class. ;)

Regards - Xaron
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

In PHP or ASP you can call those classes different you know...
Xaron
Posts: 310
Joined: Sun Oct 16, 2005 7:39 am
Location: Germany
Contact:

Post by Xaron »

Yes, and there are no classes in the good old pascal. Lisp and Prolog are different, too. ;)

Regards - Xaron
Jay

Post by Jay »

this whole class cannot exist because it is impossible to make an instance of the class, because it doesn't have any member variables.

a class needs the following:
-at least one member variable

also, a class can have member functions that operate with the member variables.

When there are only functions in a class it is sometimes better to get rid of that class and make it a namespace instead.

namespace RPG_calls
{
void RPG_go(char* calls);
};

void RPG_calls::RPG_go(char*calls)
{
;
};

that way you will be calling the function simply by

RPG_calls::RPG_go("Test");
->A namespace is like a class/structure but without member variables


As for a MMORPG - a RPG is difficult enough already...

I hope this helps.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Xaron wrote:Yes, and there are no classes in the good old pascal. Lisp and Prolog are different, too. ;)

Regards - Xaron
Prolog is evil! :shock:
Image Image Image
Post Reply