Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters > C/C++
Register

Reply
 
LinkBack Thread Tools
Old 05.05.2006, 11:23   #1
Младенец
 
tiko_www's Avatar
 
Join Date: 03 2006
Location: Yerevan
Age: 32
Posts: 20
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Exclamation կարամ 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'

ինչ անեմ աշխատի
Reply With Quote
Old 05.05.2006, 11:25   #2
...overwined...
 
noone's Avatar
 
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Downloads: 3
Uploads: 0
Reputation: 158 | 3
Default Re: կարամ CArray -ի մեջ ունենամ CArray ???

copy constructor напиши...
Reply With Quote
Old 05.05.2006, 11:34   #3
Младенец
 
tiko_www's Avatar
 
Join Date: 03 2006
Location: Yerevan
Age: 32
Posts: 20
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default Re: կարամ CArray -ի մեջ ունենամ CArray ???

ում constructor -ը որտեղ գրեմ ?
Reply With Quote
Old 05.05.2006, 11:39   #4
...overwined...
 
noone's Avatar
 
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Downloads: 3
Uploads: 0
Reputation: 158 | 3
Default Re: կարամ CArray -ի մեջ ունենամ CArray ???

он не знает как присвоить один struct_DrugsMemory другому struct_DrugsMemory...
нужен copy constructor для етого класса...
Reply With Quote
Old 05.05.2006, 11:47   #5
Младенец
 
tiko_www's Avatar
 
Join Date: 03 2006
Location: Yerevan
Age: 32
Posts: 20
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default Re: կարամ CArray -ի մեջ ունենամ CArray ???

չգիտեմ ինչ գրեմ, եթե կարաս գրի էլի
Reply With Quote
Old 05.05.2006, 12:00   #6
The splendid
 
AvDav's Avatar
 
Join Date: 07 2004
Location: Pure thoughts
Age: 36
Posts: 3,408
Downloads: 22
Uploads: 0
Reputation: 222 | 3
Default 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?
Reply With Quote
Old 05.05.2006, 12:01   #7
...overwined...
 
noone's Avatar
 
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Downloads: 3
Uploads: 0
Reputation: 158 | 3
Default Re: կարամ CArray -ի մեջ ունենամ CArray ???

сенц функция авелацру классид медж:
struct_DrugsMemory( const struct_DrugsMemory &struct_DrugsMemory1 )
{
//struct_DrugsMemory1-ic andamner@ copy es anum this-i mej
}
конкрет вонц джваранум ем хима грел...
почитай про копи-конструкторы...
Reply With Quote
Old 05.05.2006, 12:02   #8
...overwined...
 
noone's Avatar
 
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Downloads: 3
Uploads: 0
Reputation: 158 | 3
Default Re: կարամ CArray -ի մեջ ունենամ CArray ???

Quote:
Originally Posted by AvDav
P.S. es typedefery xi es anum?
хастат с-программера...
Reply With Quote
Old 05.05.2006, 12:50   #9
Младенец
 
tiko_www's Avatar
 
Join Date: 03 2006
Location: Yerevan
Age: 32
Posts: 20
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default Re: կարամ CArray -ի մեջ ունենամ CArray ???

noone OK!

Last edited by tiko_www; 05.05.2006 at 19:13.
Reply With Quote
Old 05.05.2006, 14:42   #10
Младенец
 
tiko_www's Avatar
 
Join Date: 03 2006
Location: Yerevan
Age: 32
Posts: 20
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default 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
Reply With Quote
Old 05.05.2006, 14:44   #11
...overwined...
 
noone's Avatar
 
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Downloads: 3
Uploads: 0
Reputation: 158 | 3
Default Re: կարամ CArray -ի մեջ ունենամ CArray ???

нуйн ел struct_Drugs_Element-и хамар...
Reply With Quote
Old 05.05.2006, 14:45   #12
...overwined...
 
noone's Avatar
 
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Downloads: 3
Uploads: 0
Reputation: 158 | 3
Default Re: կարամ CArray -ի մեջ ունենամ CArray ???

стех инч пах ка:
код пити грес, вор ми массивиц уриш копи ани...
Reply With Quote
Old 05.05.2006, 19:08   #13
Младенец
 
tiko_www's Avatar
 
Join Date: 03 2006
Location: Yerevan
Age: 32
Posts: 20
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default 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 19:50.
Reply With Quote
Old 06.05.2006, 10:27   #14
Младенец
 
tiko_www's Avatar
 
Join Date: 03 2006
Location: Yerevan
Age: 32
Posts: 20
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default 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));
չի ավելացնում էլեմենտներ ???
Reply With Quote
Old 06.05.2006, 11:47   #15
...overwined...
 
noone's Avatar
 
Join Date: 03 2003
Location: ...tortuga...
Posts: 3,429
Downloads: 3
Uploads: 0
Reputation: 158 | 3
Default Re: կարամ CArray -ի մեջ ունենամ CArray ???

им мот авелацнума...
байц вор компиляция линер сенц тог ем авелацрел, default constructor:
struct_DrugsMemory(): m_Name() {}
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 03:16.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.