Hi there.
Newbie alert incoming :-)
Im trying to learn some C++ Just for the fun of it, but there are something that i dont really understand.
I am trying to create a very simple program, but using multiply files. Just because i want to figure out how it works i have sorta made 3 files. I know this proberly dodent make any sense. and there are smarter ways to do it.
But im kinda just doing this because i want to figure out how i can work with mulitply files and have my functions in class.cpp files.
I do have some big problems to understand classes and functions.
My program is sorta made up from these files
Main.cpp
Choise.cpp ( intended this to be some kinda menu class)
Poker.cpp ( where the actual poker calculations takes place)
Choise.h
Poker.h
In my main.cpp
I am calling a function from the poker class. and i want to print out the return value from the function.
How do i do this. Is it even posibel or am I doing something wrong, or maybe i just dont understand it ?
Main.cpp
Code:
#include "Choise.h"
#include "Poker.h"
using namespace std;
int main(){
Choise choise1("valg \n");
char uservalg = choise1.userChoise();
if (uservalg == 1){
cout << "You chose to enter the size of the pot. \n\n";
// call function enter PotSize from poker class
}
if (uservalg == 2){
cout << "You chose to bet. \n\n";
Poker bet;
bet.betIntoPot();
// Here I want to print out the return value from the function betIntoPot from the Poker.cpp file.
}
if (uservalg == 3){
cout << "You chose to call a bet. \n\n";
// call function callBet from poker class
}
system("PAUSE");
return 0;
}
poker.cpp
Code:
#include <iostream>
#include "Poker.h"
Poker::Poker()
{
}
float Poker::potSize()
{
float potSize;
cout << "Enter the size of the pot before you action \n\n";
cin >> potSize;
return potSize;
}
int Poker::betIntoPot()
{
int betSize;
cout << "Enter size of your bet \n\n";
cin >> betSize;
cout << "You have bet " << betSize << " into the pot.\n\n";
return betSize;
}
int Poker::callBet()
{
int call;
cout << "Enter size of bet to call\n\n";
cin >> call;
return call;
}
So far the program runs with out any errors. But I just dont know how to use the return (betSize) value from the betIntoPot function in my main program.
Is it even posibel to do this ?