I've removed your code since the amount of bugs and incompleteness is beyond repair or reproduction.
So here is the basic setup for your question (wich is actually BAD programming so read on:
Besides placing your sourcecode between the "CODE" tags, also disable smilies when posting code. You can see the option just below the post-editor.
Code:
//Below Main.cpp
#include "blackjack.h"
int main()
{
blackjack bj;
bj.SetTestValue(12);
bj.PrintTestValue();
return 0;
}
//Below playingcards.h
#ifndef PLAYINGCARDS_H
#define PLAYINGCARDS_H
#include <iostream>
using namespace std;
class card
{
public:
int m_testvalue;
void PrintTestValue()
{
cout<<m_testvalue<<endl;
}
};
#endif //PLAYINGCARDS_H
//Below blackjack.h
#ifndef BLACKJACK_H
#define BLACKJACK_H
#include "playingcards.h"
#include <iostream>
using namespace std;
class blackjack : public card
{
public:
void SetTestValue( int n )
{
m_testvalue = n;
}
};
#endif //BLACKJACK_H
The problem now is that
int m_testvalue is made public. Basically, members should be declared private!
So the answer to your question is: you can't.
That's because the program design isn't very good.
SO...
The way to solve this is NOT to make "blackjack" a derrived class from "card". Instead use
aggregation. Basically you compose the class "blackjack" by adding a "card" object to the "blackjack" class.
So here is the code (observe
card TheCards) . That is the aggregate!:
Code:
{
private:
int m_testvalue;
public:
void Set(int n)
{
m_testvalue = n;
}
int Get()
{
return m_testvalue;
}
void PrintTestValue()
{
cout<<m_testvalue<<endl;
}
};
//-------------------------------------------------------------------
#include "playingcards.h"
#include <iostream>
using namespace std;
class blackjack
{
public:
void SetTestValue(int n)
{
TheCards.Set(n);
}
void PrintTestValue()
{
cout << TheCards.Get() << endl;;
}
private:
card TheCards;
};
You can use the same Main() function.