[question] switch/class/struct

Posts 19 of 9 · Page 1 of 1
[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.
i havent seen enums much lately. I guess use alternatives /

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



Quote Originally Posted by Auxilium 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.
[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.
Small correction ...

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

SomeFunction(Void);
}
[/Highlight]
Quote Originally Posted by why06 View Post
Small correction ...

NOBODY ASKED YOU.
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;
	}
}
Figured it out thanks guys !
Unable to +rep why
Posts 19 of 9 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Need help?