Hello I am really scratching my head around this ,i want to create a class function with more than one option
Someathing like
I don't really know for what to look for (basically a class whithin a class whithin a class and so on)... so i'll give an example:

Events.add.coord();
or
Events.add.zone();
or
Events.add.copy.id();
or
Events.add.someathing.someathing.byref();

I don't think the class in a class in a class would work to good so i came here for some aid.
Or the creation of functions like "void Events.add.zone(){};"

Ok, so I don't know if this is what you are looking for:

#include <iostream>

using namespace std;

template<typename Type>
class Events {

    public:

        virtual void add() {
            Type s;
            s.add();
        }
};

class Coord {

    public:

        void add()
        {
            cout << "Added Coord" << endl;
        }   
};

class Zone {

    public:

        void add()
        {
            cout << "Added Zone" << endl;
        }
};

int main(int argc, char *argv[]) {
    Events<Coord> coord;
    Events<Zone> zone;

    coord.add();
    zone.add();
}



// output:
    Added Coord
    Added Zone

Obviously, your return type would have to be different. I'm really tired so I can't think of another way to implement your question :(!

Well, you can have multiple single classes, and than to have an instance of some classes in another classes. Here's a quick example:

#include <iostream>
using namespace std;

class A{
public:
    A(){}
    char* addA(){return "addA\n";}
};

class B{
public:
    A a; //public instance of class A in class B;
    B(){}
    char* addB(){return "addB\n";}
};

class C{
public:
    B b; //public instance of class B in class C;
    C(){}
    char* addC(){return "addC\n";}
};

int main (){
    C c;
    cout<<c.addC()
        <<c.b.addB()
        <<c.b.a.addA();
}

By putting in B and C public instances of class A and B respectively, I could access, having only 1 instance of class C all the members from C, B and A.

Lucaci Andrew i've been using that method for a while now but i'm not comfident that this method is the best one to use.
Take for example a game development menu (opend usualy whit the key ~ :: console key),

Equipitem.ItemID.left //|| right (this is from a game not gonna say)

This is the kind of thing i'm trying to achive if you could provide an example i'd appreciate it .

Lucaci Andrew i've been using that method for a while now but i'm not comfident that this method is the best one to use.

That's the only way you're going to get the syntax you want, given that the membership operator can't be overloaded. Are you sure that the game is interpreting C++? Usually those console commands are a DSL.

deceptikon take it as an example
I'm not trying to use a game/gameengine/explot/mod, i'm trying to make a game and right now i'm doing the basic functions ,
event handler display sound ,core esentially.And i want it to be extremely well defined so that in the future it won't pose a problem.
here let me be more clear

#include <iostream>
#unsing namespace std;

#include "some_class.h"
void main () 
{
    class some_class;
    //the thing i want to reproduce.

    some_class setVariabile (variabil_name variabile_value);
    some_class.a_class_whithin_the_class.variabil_name.doSomeathing();


}

Basicly i got the the point if i want to extend my functions i want to create a class fro them (i was doing that already but diden't seem to be the most efficient way),i've tryed using structs but there's a catch they don't handle too well outside variabiles.

The first question i'm asking is there a better way to handle this action other than classes (i don't care if it's a bit harder to implement as long as the end function is better implemented) - if it's a no i'm ok with that.

The secon question is there any way to dinamicly create a variabile better yet a variabile that's created in a class whit the name given in a function(variabile_name) and a value (variabile_value) if not at least a way to set the variabile and the end result funcion to look someathing like:

    some_class setVariabile (value);
    some_class.a_class_whithin_the_class.Variabile.doSomeathing();

I apologise for the typing,i'm typing in a hurry and i'm not correcting my spelling (google FTW).And thanks for all the feedback so far!

i've tryed using structs but there's a catch

The real catch is that structs are classes.

The first question i'm asking is there a better way to handle this action other than classes

No.

The secon question is there any way to dinamicly create a variabile better yet a variabile that's created in a class whit the name given in a function(variabile_name) and a value (variabile_value)

No. You can store the "variables" in a map using the name for your key:

some_class.map_of_nested_class["Variable"].doSomething();

But the type for "Variable" has to exist itself as a class, it won't be dynamically generated. C++ is not well suited to the kind of dynamic/variant programming style you seem to want.

The idea came when I was messing around with the Windows.h
INPUT_RECORD eventBuffer;
I saw this line of code
eventBuffer[i].Event.KeyEvent.wVirtualKeyCode==VK_ESCAPE; //this is actually legit
event buffer (variabile,actualy a struct) . class(or smth) . class . function == VK_ESCAPE
and then it got intoo my head and started wondering how to replicate and then how to add variabiles in the middle and instead of (int somenomber , char * orsomechar) it adds a == VK_ESCAPE that actually i'm kinda figuring it out somewhat
corect me if i'm wrong

struct IMPUT_RECORD 
{
    struct Event
    {
        struct||class KeyEvent
        {
            void wVirtualKeyCode()
            {
                cout << "Do function here";
            };
        }
    }
}IMPUT_RECORD;

not on the spelling ofc.
this could be my last post before going to work in 10 15 else see you in 8 h or tomorow :P
this is kinda interesting as i don't know too many Low level programmers ,talking with someone that actually knows more than i do :P

corect me if i'm wrong

Well, that's not how INPUT_RECORD is defined, but as a concept for what you want to do it's fine. If you're interested, INPUT_RECORD is defined like this:

typedef struct _INPUT_RECORD {
    WORD EventType;
    union {
        KEY_EVENT_RECORD KeyEvent;
        MOUSE_EVENT_RECORD MouseEvent;
        WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
        MENU_EVENT_RECORD MenuEvent;
        FOCUS_EVENT_RECORD FocusEvent;
    } Event;
} INPUT_RECORD;

And KEY_EVENT_RECORD looks like this:

typedef struct _KEY_EVENT_RECORD {
    BOOL bKeyDown;
    WORD wRepeatCount;
    WORD wVirtualKeyCode;
    WORD wVirtualScanCode;
    union {
        WCHAR UnicodeChar;
        CHAR   AsciiChar;
    } uChar;
    DWORD dwControlKeyState;
} KEY_EVENT_RECORD;

The other members of the union look like this:

typedef struct _MOUSE_EVENT_RECORD {
    COORD dwMousePosition;
    DWORD dwButtonState;
    DWORD dwControlKeyState;
    DWORD dwEventFlags;
} MOUSE_EVENT_RECORD;

typedef struct _WINDOW_BUFFER_SIZE_RECORD {
    COORD dwSize;
} WINDOW_BUFFER_SIZE_RECORD;

typedef struct _MENU_EVENT_RECORD {
    UINT dwCommandId;
} MENU_EVENT_RECORD;

typedef struct _FOCUS_EVENT_RECORD {
    BOOL bSetFocus;
} FOCUS_EVENT_RECORD;

Not overly complicated, but you should be able to see the nested structure. The intended usage isn't quite what you're thinking of, but the classes you've derived from it should work for your purpose.

Yeah the F12 worked for me too but diden't say nested class :P or MSNDA :P i'll look up nested classes more there seems to be someathing behind the, Thanks for all the feedback i'll be comming back for more problems arrise , and if you guys are interested in helping a bit in the future ;P

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.