Results 1 to 9 of 9
  1. #1
    mookamoka3's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    110
    Reputation
    14
    Thanks
    13

    [question] switch/class/struct

    I'll just give a big beefy example :

    Code:
    #include "stdafx.h"
    #include <iostream>
    
    using namespace std;
    
    void ChoosePosition(sex positions);
    
    enum sex
    {
    	doggystyle,
    	butterfly,
    	anal,
    	missionary,
    };
    
    
    int _tmain(int argc, _TCHAR* argv[],sex positions)
    {
    	ChoosePosition(sex positions);
    
    return 0;
    }
    
    void ChoosePosition(sex position){
    	switch(position){
    	case(doggystyle):
    			cout<<"ROUGHH!"<<endl;
    	case(anal):
    		cout<<"kinky."<<endl;
    		break;
    	case(missionary):
    		cout<<"normal i guess."<<endl;
    		break;
    	case(butterfly):
    		cout<<"I dont even know what this is..."<<endl;
    		break;
    	default:
    		cout<<"whatever you want it to be baby"<<endl;
    		break;
    	}
    }
    (my issue is that this code is wrong. I need to figure out how to properly call a function, if that function contains variables from a struct, class, enum or basically anything.) <--- Not sure if this makes sense .

    actually just so it's easier for me to understand cuz my brain isnt workin so great right now, i basically need to know how to call ChoosePosition(sex positions); in my main function in this situation.

  2. #2
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    i havent seen enums much lately. I guess use alternatives /

    i think the problem is that you declared the enum after your function prototype.



    Last edited by Auxilium; 02-05-2011 at 10:03 PM.

  3. #3
    mookamoka3's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    110
    Reputation
    14
    Thanks
    13
    Quote Originally Posted by Koreans View Post
    i havent seen enums much lately. I guess use alternatives /

    i think the problem is that you declared the enum after your function prototype.



    Nah i tried that, didn't work

    I'm baffled

    The same thing seems to happen for structs and classes though. If i make a struct outside of a function, make a function that uses the variables, and then try to call it in the main function it doesnt work. The error is always that the type in the function call is invalid.. so i try different types and i took the type out altogether and it just says that its undefined XD. Even when I took everything out of the brackets it says that there's too few arguements.

    STUMPED.

  4. #4
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    [Highlight=C++]

    struct Person
    {
    char* name;
    int age;
    }

    void SomeFunction(Person instance)
    {
    cout << instance.name;
    return;
    }

    int main()
    {
    Person Void;
    Void.name = "Idk";
    Void.age = 14;

    SomeFunction(Void);
    }
    [/Highlight]

    Code:
    Output: "Idk"
    NOTE: void is a data type but in this case I was using my username as a variable name, don't think of it as the void data type.

  5. The Following User Says Thank You to Void For This Useful Post:

    mookamoka3 (02-05-2011)

  6. #5
    master131's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    Melbourne, Australia
    Posts
    8,858
    Reputation
    3438
    Thanks
    101,669
    My Mood
    Breezy
    Move the enum above the function prototype..

    This is what I used, worked for me:
    Code:
    #include <iostream>
    
    using namespace std;
    
    enum sex
    {
    	doggystyle,
    	butterfly,
    	anal,
    	missionary,
    };
    
    void ChoosePosition(sex positions);
    
    int main()
    {
    	ChoosePosition(sex(doggystyle));
    
    	return 0;
    }
    
    void ChoosePosition(sex position){
    	switch(position){
    	case(doggystyle):
    			cout<<"ROUGHH!"<<endl;
    	case(anal):
    		cout<<"kinky."<<endl;
    		break;
    	case(missionary):
    		cout<<"normal i guess."<<endl;
    		break;
    	case(butterfly):
    		cout<<"I dont even know what this is..."<<endl;
    		break;
    	default:
    		cout<<"whatever you want it to be baby"<<endl;
    		break;
    	}
    }
    Donate:
    BTC: 1GEny3y5tsYfw8E8A45upK6PKVAEcUDNv9


    Handy Tools/Hacks:
    Extreme Injector v3.7.3
    A powerful and advanced injector in a simple GUI.
    Can scramble DLLs on injection making them harder to detect and even make detected hacks work again!

    Minion Since: 13th January 2011
    Moderator Since: 6th May 2011
    Global Moderator Since: 29th April 2012
    Super User/Unknown Since: 23rd July 2013
    'Game Hacking' Team Since: 30th July 2013

    --My Art--
    [Roxas - Pixel Art, WIP]
    [Natsu - Drawn]
    [Natsu - Coloured]


    All drawings are coloured using Photoshop.

    --Gifts--
    [Kyle]

  7. The Following User Says Thank You to master131 For This Useful Post:

    mookamoka3 (02-05-2011)

  8. #6
    mookamoka3's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    110
    Reputation
    14
    Thanks
    13
    Figured it out thanks guys !

  9. #7
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Small correction ...

    Quote Originally Posted by Void View Post
    [Highlight=C++]
    int main()
    {
    Person Void;
    Void.name = "PedoWaldo";
    Void.age = 23;

    SomeFunction(Void);
    }
    [/Highlight]

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  10. The Following 2 Users Say Thank You to why06 For This Useful Post:

    Hell_Demon (02-06-2011),[MPGH]master131 (02-06-2011)

  11. #8
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by why06 View Post
    Small correction ...

    NOBODY ASKED YOU.

  12. The Following User Says Thank You to Void For This Useful Post:

    Hell_Demon (02-06-2011)

  13. #9
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Unable to +rep why
    Ah we-a blaze the fyah, make it bun dem!