Click here to Skip to main content
15,918,889 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: creating an array of objects dynamically Pin
erfi20-Sep-06 1:59
erfi20-Sep-06 1:59 
GeneralRe: creating an array of objects dynamically Pin
toxcct20-Sep-06 2:06
toxcct20-Sep-06 2:06 
GeneralRe: creating an array of objects dynamically Pin
erfi20-Sep-06 2:09
erfi20-Sep-06 2:09 
GeneralRe: creating an array of objects dynamically Pin
Zac Howland20-Sep-06 3:46
Zac Howland20-Sep-06 3:46 
AnswerRe: creating an array of objects dynamically Pin
_AnsHUMAN_ 20-Sep-06 2:14
_AnsHUMAN_ 20-Sep-06 2:14 
GeneralRe: creating an array of objects dynamically Pin
erfi20-Sep-06 2:55
erfi20-Sep-06 2:55 
GeneralRe: creating an array of objects dynamically Pin
benjymous20-Sep-06 3:25
benjymous20-Sep-06 3:25 
GeneralRe: creating an array of objects dynamically [modified] Pin
_AnsHUMAN_ 20-Sep-06 3:33
_AnsHUMAN_ 20-Sep-06 3:33 
erfi wrote:
"error C2512: 'Row' : no appropriate default constructor available"

try providing a default constructor in your class.
erfi wrote:
allocate the memory for Row object's member with a member function of Row.

What's the problem with allocation of memory in the constructor itself.
Here's the code for you:
#include "stdafx.h"
#include <iostream>
using namespace std;
class Row
{
private:
	char *termState;  
	int *terms;    
public:
	Row()
	{
		cout<<"In edefau"<<endl;
	}
	Row(int length,int mTCount);
	void Display(); 
};
Row::Row(int a,int b)
{
	cout<<"Constructor of the row class is invoked"<<endl;
	// allocate memory using new
	termState=new char[a];
	terms=new int[b];

}
void Row::Display ()
{
	// example
	cout<<"Display of row class";
}
// Class table
class Table
{
private:
        Row *rows;
public:
        Table(int);
};
Table::Table(int a)
{
		rows=new Row [a];
		rows->Display();
}
int _tmain(int argc, _TCHAR* argv[])
{
	Table t(10);
	return 0;
}

Try this out and let me know whether there exist some more problem..


-- modified at 9:42 Wednesday 20th September, 2006

Somethings seem HARD to do, until we know how to do them.
Wink | ;-) _AnShUmAn_

GeneralRe: creating an array of objects dynamically Pin
toxcct20-Sep-06 4:35
toxcct20-Sep-06 4:35 
QuestionCFile Pin
Sonia Horra20-Sep-06 1:39
Sonia Horra20-Sep-06 1:39 
AnswerRe: CFile Pin
_AnsHUMAN_ 20-Sep-06 1:42
_AnsHUMAN_ 20-Sep-06 1:42 
GeneralRe: CFile Pin
Sonia Horra20-Sep-06 2:52
Sonia Horra20-Sep-06 2:52 
GeneralRe: CFile Pin
Hamid_RT20-Sep-06 7:36
Hamid_RT20-Sep-06 7:36 
AnswerRe: CFile Pin
pavan_sw20-Sep-06 20:53
pavan_sw20-Sep-06 20:53 
QuestionAbout windows Events Pin
janadhana20-Sep-06 1:09
janadhana20-Sep-06 1:09 
AnswerRe: About windows Events Pin
Mr.Brainley20-Sep-06 2:21
Mr.Brainley20-Sep-06 2:21 
GeneralRe: About windows Events Pin
janadhana21-Sep-06 2:04
janadhana21-Sep-06 2:04 
QuestionA Simple Namespace Extension Question Pin
Dave Kerr20-Sep-06 0:57
Dave Kerr20-Sep-06 0:57 
QuestionCan I call the open folder dialog directly? Pin
BarryOg20-Sep-06 0:40
BarryOg20-Sep-06 0:40 
AnswerRe: Can I call the open folder dialog directly? Pin
Christian Graus20-Sep-06 0:51
protectorChristian Graus20-Sep-06 0:51 
QuestionRe: Can I call the open folder dialog directly? Pin
BarryOg20-Sep-06 0:59
BarryOg20-Sep-06 0:59 
AnswerRe: Can I call the open folder dialog directly? Pin
Haroon Sarwar20-Sep-06 1:27
Haroon Sarwar20-Sep-06 1:27 
GeneralRe: Can I call the open folder dialog directly? Pin
BarryOg20-Sep-06 2:01
BarryOg20-Sep-06 2:01 
QuestionProfiling help request. Pin
cpp_prgmer20-Sep-06 0:33
cpp_prgmer20-Sep-06 0:33 
AnswerRe: Profiling help request. Pin
Dave Kerr20-Sep-06 1:12
Dave Kerr20-Sep-06 1:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.