 |
կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 10:23
|
#1
|
Младенец
Join Date: 03 2006
Location: Yerevan
Age: 39
Posts: 20
Rep Power: 0
|
կարամ CArray -ի մեջ ունենամ CArray ???
CArray -ու ուզում եմ ունենամ մեկ այլ CArray ինչ-որ arror ա տալիս
գրել եմ հետևյալը
/////////////////////////////////////////////////////
class struct_Drugs_Element{
public:
struct_Drugs_Element( long ID = 0)
{
m_ID = ID;
};
long m_ID;
};
typedef CArray<struct_Drugs_Element, struct_Drugs_Element> typedef_Drugs_Element;
//============================
class struct_DrugsMemory{
public:
struct_DrugsMemory(CString Name = "")
{
m_Name = Name;
m_El.Add(struct_Drugs_Element(2));
};
CString m_Name;
typedef_Drugs_Element m_El;
};
typedef CArray<struct_DrugsMemory, struct_DrugsMemory> typedef_struct_Drugs;
...
...
typedef_struct_Drugs m_DrugsMemory;
m_DrugsMemory.Add(struct_DrugsMemory("adl"));
error C2664: 'Add' : cannot convert parameter 1 from 'class struct_DrugsMemory' to 'class struct_DrugsMemory'
No copy constructor available for class 'struct_DrugsMemory'
ինչ անեմ աշխատի
|
|
|
 |
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 10:25
|
#2
|
...overwined...
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Rep Power: 5
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
copy constructor напиши...
__________________
...let's be gods... let's by ugly...
|
|
|
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 10:34
|
#3
|
Младенец
Join Date: 03 2006
Location: Yerevan
Age: 39
Posts: 20
Rep Power: 0
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
ում constructor -ը որտեղ գրեմ ?
|
|
|
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 10:39
|
#4
|
...overwined...
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Rep Power: 5
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
он не знает как присвоить один struct_DrugsMemory другому struct_DrugsMemory...
нужен copy constructor для етого класса...
__________________
...let's be gods... let's by ugly...
|
|
|
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 10:47
|
#5
|
Младенец
Join Date: 03 2006
Location: Yerevan
Age: 39
Posts: 20
Rep Power: 0
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
չգիտեմ ինչ գրեմ, եթե կարաս գրի էլի
|
|
|
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 11:00
|
#6
|
Ego coder
Join Date: 07 2004
Location: Yerevan, Armenia
Age: 44
Posts: 3,738
Rep Power: 5
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
Code:
struct struct_DrugsMemory
{
struct_DrugsMemory(const CString& Name = "") : m_Name(Name)
{m_El.Add(struct_Drugs_Element(2));}
struct_DrugsMemory(const struct_DrugsMemory& obj) : m_Name(obj.m_Name), m_El(obj.m_El) {}
private:
CString m_Name;
typedef_Drugs_Element m_El;
};
P.S. es typedeferin senc erkar anun taly harmara?
__________________
Каждый сам кузнец своего счастья, и несчастья тоже.
|
|
|
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 11:01
|
#7
|
...overwined...
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Rep Power: 5
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
сенц функция авелацру классид медж:
struct_DrugsMemory( const struct_DrugsMemory &struct_DrugsMemory1 )
{
//struct_DrugsMemory1-ic andamner@ copy es anum this-i mej
}
конкрет вонц джваранум ем хима грел...
почитай про копи-конструкторы...
__________________
...let's be gods... let's by ugly...
|
|
|
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 11:02
|
#8
|
...overwined...
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Rep Power: 5
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
Quote:
Originally Posted by AvDav
P.S. es typedefery xi es anum?
|
хастат с-программера...
__________________
...let's be gods... let's by ugly...
|
|
|
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 11:50
|
#9
|
Младенец
Join Date: 03 2006
Location: Yerevan
Age: 39
Posts: 20
Rep Power: 0
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
noone OK!
Last edited by tiko_www; 05.05.2006 at 18:13.
|
|
|
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 13:42
|
#10
|
Младенец
Join Date: 03 2006
Location: Yerevan
Age: 39
Posts: 20
Rep Power: 0
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
noone OK! 
AvDav
կայնում ա վրեն
Code:
struct_DrugsMemory(const struct_DrugsMemory& obj) : m_Name(obj.m_Name), m_El(obj.m_El)
{
}
error C2558: class 'CArray<class struct_Drugs_Element,class struct_Drugs_Element>' : no copy constructor available
|
|
|
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 13:44
|
#11
|
...overwined...
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Rep Power: 5
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
нуйн ел struct_Drugs_Element-и хамар...
__________________
...let's be gods... let's by ugly...
|
|
|
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 13:45
|
#12
|
...overwined...
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Rep Power: 5
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
стех инч пах ка:
код пити грес, вор ми массивиц уриш копи ани...
__________________
...let's be gods... let's by ugly...
|
|
|
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
05.05.2006, 18:08
|
#13
|
Младенец
Join Date: 03 2006
Location: Yerevan
Age: 39
Posts: 20
Rep Power: 0
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
Code:
struct struct_Drugs_Element{
public:
struct_Drugs_Element(const int& Parent_ID = 0/*, const long& ID = 0,const CString& Name = "",const CString& Company = "",const COleDateTime& Date = COleDateTime(1996,1,1,0,0,0),const CString& More_Info = "",const short& Count = 0,const short& Cost = 0*/)
{
m_Parent_ID = Parent_ID;
/* m_ID = ID;
m_Name = Name;
m_Company = Company;
m_Date = Date;
m_More_Info = More_Info;
m_Count = Count;
m_Cost = Cost;
*/
}
struct_Drugs_Element(const struct_Drugs_Element& obj) : m_Parent_ID(obj.m_Parent_ID)/*, m_ID(obj.m_ID), m_Name(obj.m_Name), m_Company(obj.m_Company), m_Date(obj.m_Date), m_More_Info(obj.m_More_Info), m_Count(obj.m_Count), m_Cost(obj.m_Cost)*/
{
}
int m_Parent_ID;
/* long m_ID;
CString m_Name;
CString m_Company;
COleDateTime m_Date;
CString m_More_Info;
short m_Count;
short m_Cost;
*/ };
typedef CArray<struct_Drugs_Element, struct_Drugs_Element> typedef_Drugs_Element;
/////////////////////////////////////////////////////////////
//memory strycture
struct struct_DrugsMemory
{
public:
struct_DrugsMemory(const CString& Name = "") : m_Name(Name)
{
m_El.Add(struct_Drugs_Element(2));
}
struct_DrugsMemory(const struct_DrugsMemory& obj)// : m_El(obj.m_El)//, m_Name(obj.m_Name)
{
m_Name = obj.m_Name;
for(int i = 0; i < obj.m_El.GetSize(); i++)
{
m_El.Add(6);
}
}
CString m_Name;
typedef_Drugs_Element m_El;
};
////////////////////////////////////////
typedef CArray<struct_DrugsMemory, struct_DrugsMemory> typedef_struct_Drugs;
error C2582: 'struct_DrugsMemory' : 'operator =' function is unavailable
եղբայր չի լինում
Last edited by tiko_www; 05.05.2006 at 18:50.
|
|
|
 |
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
06.05.2006, 09:27
|
#14
|
Младенец
Join Date: 03 2006
Location: Yerevan
Age: 39
Posts: 20
Rep Power: 0
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
ավելացրեցի
struct_DrugsMemory& operator= (const struct_DrugsMemory& obj)
Code:
struct struct_Drugs_Element{
public:
struct_Drugs_Element(const int& Parent_ID = 0/*, const long& ID = 0,const CString& Name = "",const CString& Company = "",const COleDateTime& Date = COleDateTime(1996,1,1,0,0,0),const CString& More_Info = "",const short& Count = 0,const short& Cost = 0*/)
{
m_Parent_ID = Parent_ID;
/* m_ID = ID;
m_Name = Name;
m_Company = Company;
m_Date = Date;
m_More_Info = More_Info;
m_Count = Count;
m_Cost = Cost;
*/
}
struct_Drugs_Element(const struct_Drugs_Element& obj) : m_Parent_ID(obj.m_Parent_ID)/*, m_ID(obj.m_ID), m_Name(obj.m_Name), m_Company(obj.m_Company), m_Date(obj.m_Date), m_More_Info(obj.m_More_Info), m_Count(obj.m_Count), m_Cost(obj.m_Cost)*/
{
}
int m_Parent_ID;
/* long m_ID;
CString m_Name;
CString m_Company;
COleDateTime m_Date;
CString m_More_Info;
short m_Count;
short m_Cost;
*/ };
typedef CArray<struct_Drugs_Element, struct_Drugs_Element> typedef_Drugs_Element;
/////////////////////////////////////////////////////////////
//memory strycture
struct struct_DrugsMemory
{
public:
struct_DrugsMemory(const CString& Name = "") : m_Name(Name)
{
m_El.RemoveAll();
// AfxMessageBox("const");
// m_El.Add(struct_Drugs_Element(5));
}
struct_DrugsMemory(const struct_DrugsMemory& obj)// : m_El(obj.m_El)//, m_Name(obj.m_Name)
{
m_Name = obj.m_Name;
// AfxMessageBox("copy const");
for(int i = 0; i < obj.m_El.GetSize(); i++)
{
m_El.Add(struct_Drugs_Element(obj.m_El.GetAt(i).m_Parent_ID));
}
}
struct_DrugsMemory& operator= (const struct_DrugsMemory& obj)
{
m_Name = obj.m_Name;
// m_El.RemoveAll();
// AfxMessageBox("operator=");
for(int i = 0; i < obj.m_El.GetSize(); i++)
{
m_El.Add(struct_Drugs_Element(obj.m_El.GetAt(i).m_Parent_ID));
}
return *this;
}
CString m_Name;
typedef_Drugs_Element m_El;
};
typedef CArray<struct_DrugsMemory, struct_DrugsMemory> typedef_struct_Drugs;
///////
int a;
a = m_DrugsMemory.Add(struct_DrugsMemory("dfhdfh"));
m_DrugsMemory.GetAt(a).m_El.Add(struct_Drugs_Element(5));
m_DrugsMemory.GetAt(a).m_El.Add(struct_Drugs_Element(6));
m_DrugsMemory.GetAt(a).m_El.Add(struct_Drugs_Element(9));
չի ավելացնում էլեմենտներ ???
|
|
|
 |
 |
Re: կարամ CArray -ի մեջ ունենամ CArray ??? |
 |
06.05.2006, 10:47
|
#15
|
...overwined...
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Rep Power: 5
|
Re: կարամ CArray -ի մեջ ունենամ CArray ???
им мот авелацнума...
байц вор компиляция линер сенц тог ем авелацрел, default constructor:
struct_DrugsMemory(): m_Name() {}
__________________
...let's be gods... let's by ugly...
|
|
|
All times are GMT. The time now is 04:37. |
|
|