struct - c++ Constructor initialization with instance of structure -


don't know how put m_performance get_performance

struct performance {     double high;     double average;     double low; }perf; 

create structure

class strategy { public: performance m_performance(){     perf.high = 10.1;     perf.average =5.1;     perf.low =1.1; }; void get_performance(){     m_performance();     ///this part not work } }; 

create class & insert method, get_performance. something's wrong.

int _tmain(int argc, _tchar* argv[]) {     strategy a;     cout << a.get_performance << endl;     return 0; } 

wanna data member structure

if understood correctly, should:

struct performance {     double high;     double average;     double low; };  class strategy {  private:     performance m_performance; public:     strategy() {         m_performance.high = 10.1;         m_performance.average = 5.1;         m_performance.low = 1.1;     }     performance get_performance() {        return m_performance;     } };  int _tmain(int argc, _tchar* argv[]) {     strategy a;     performance p = a.get_performance();     return 0; } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -