Home > Software engineering >  Class members have container, for object assignment is not successful problem ~ ~
Class members have container, for object assignment is not successful problem ~ ~

Time:04-13

Directly on the code that defines a segment class
 
# pragma once

#include
using namespace std;
The class line
{
Private:
Cstrings name;//curve name
The float min;//the minimum
Float Max;//Max
Public:
Vector The value;//curve values
The line (void);
~ the line (void);
The line (TCHAR * m_name, float m_min, float m_max);
Void Set_name (cstrings name);//set curve name
Void Set_min (float min);//set the minimum
Void Set_max (float Max);//set the maximum

Cstrings return_name ();//return curve name
Float return_min ();//return the minimum
Float return_max ();//returns the maximum
};

 
# include "StdAfx. H"
H # include "line."
//# include "afxtempl. H"



Line: line (void)
{
Name=_T (" ");
min=0;
Max=0;
}


The line: : ~ line (void)
{
//delete [] name;
}
Line: line (TCHAR * m_name, float m_min, float m_max)
{

This - & gt; Name=m_name;
This - & gt; Min=m_min;
This - & gt; Max=m_max;
}
Void line: : Set_name (cstrings m_name)//set name
{
This - & gt; Name=m_name;
}
Void line: : Set_min (float m_min)//set the minimum
{
This - & gt; Min=m_min;
}
Void line: : Set_max (float m_max)//set the maximum
{
This - & gt; Max=m_max;
}

Cstrings line: : return_name ()//return curve name
{
return name;
}
Float line: : return_min ()//return the minimum
{
Return min;
}
Float line: : return_max ()//return the maximum
{
The return of Max;
}

In the new object in the main program
The line NCO=line (_T (" C/O "), 0.4, 0.6);
Has built an array
The line * arrline []={& amp; NCO, & amp; NCO1};
To object container assignment NCO. Value. The push_back (5);
Finally through the array arrline [0] - & gt; The value [0] to read data, found that the result is always zero, asked the great spirit show?? Directly read NCO. Value [0] is 0, feel the value of the container can't go ~ ~ but I see NCO. Value. The capacity (); It has become a ah ~ ~
  • Related