Hi FirstPerson,

I've tweaked your code to meet your needs, I think you are trying to acheive something like this.
[code]

class Tetris {
public:
bool DrawLine(unsigned int iColId) {
cout << "Draw Line of Tetris"<<endl;
return true;
}
};

template<typename Type>
class vec2D
{

typedef bool (Tetris::*MFPtr)(unsigned int ID);
MFPtr mydrawFuncPtr;

private:
unsigned int Col_id;
public:
Type x;
Type y;

vec2D(Type x0,Type y0) : x(x0), y(y0) { }
vec2D() : x(0),y(0){ mydrawFuncPtr = 0; }

void reset() { x  = 0; y = 0; }

//Enables each object member to have its own unique draw func. 
void setDrawFunc(MFPtr drawFunc  ) {  mydrawFuncPtr = drawFunc;}

//get-set methods
unsigned int Color() { return Col_id;}

void Color(int i) { if(i < 0) Col_id = 0; else Col_id = i; }

// WRONG.
//void drawShape(vec2D<Type>& obj,unsigned int colID) 

//CORRECTED:
void drawShape(Tetris& obj,unsigned int colID) 
{       
    (obj.*mydrawFuncPtr)(colID);
}

};

int main ()
{

vec2D<int> vec2DTetris[10];         // use this array.
vec2DTetris[0].setDrawFunc(&Tetris::DrawLine);

Tetris t;
vec2DTetris[0].drawShape(t, 4);

return 0;

}
[/code]

Hope the Above Code help

@firstPerson the default Constructor & Destructor are not always trivial at the Compiler level, to users it might be...

Hi lotrsimp12345,

This usually irritates the programmer that why the compiler emits a default constructor.

Let me explain you a bit detail of how C++ standard dictate about default constructor and its semantics.

if your class contains primitive types, then your default constructor would be trivial i.e.
[code=cpp]
class Foo {
public:
int a;
}
[/code]
if we consider the Foo class its default constructor would be trivial i.e. doesn't modify the state and probably member "a" contains the garbage (or some 0xCCCCCCCC etc). Basically in C++ its always the programmer's responsiblity to intialize the values. This is what standard tells us. Logically if we look with the eye of programmer it seems irritating for us to explicitly intialize the value, yes it is, but we have some other facilities (default argument values) in the language to acheive the same.

[code=cpp]
class Foo {
Bar b;
}
[/code]

In above code Bar is the subobject which must be initialized before the intialization of Foo in this case compiler synthesized the constructor which in turns calls the default constructor for Bar. same goes for inheritance as well and obviously destructor would release the memory by calling the destructor of subobjects.

if C++ default constructor initializes the memory to "ZERO values" for primitive types then the name of default constructor should be "ZERO Constructor" :) rather than default constructor.

DangerDev commented: very informative. +3

if you are using pthread then you can use the following API.

[code]
int pthread_attr_setschedparam(pthread_attr_t tattr, const struct sched_param param);
[/code]

consult google for such questions :). it will show you more answers.

I don't understand your objective behing calling derive funciton in base at all, I understand C++ is multi paradigm language, but I can't see any logical reasoning behind this, could you please elloborate more.. so we can provide you better alternative than this, or correct any mistakes whatsoever

siddhant3s commented: So true, So true +16

difference b/w const and #define (macro).

  1. Type Checking:- macros are not type safe where as const are type safe. since the macros are replaced by definition at the time of preprocessing (which is done before compilation). the storage area of macros is not defined where as const has static storage area.

for example
[code]

define n 10

int main ()
{
// what would be the behavior of the below code.
cout<< &n<<endl;
return 0;
}
[/code]

  1. macros are error prune
    for example the below code
    [code]

define max(a,b) ((a>b)?a:b)

int main ()
{
int a = 2;
int b = 3;
cout<<max(a++, b)<<endl;
return 0;
}
[/code]
check the above code. the proper solution to above is to use templates rather than macros for specifying generic operatoins.
[see. Effective C++ for more details.].

so the conclusion is that use consts & templates where necessary don't use macros. :).

hammerhead commented: Excellent +2

_cdecl and _stdcall has some difference, I think you are calling the function from the library written using different calling convention than the one you are using. Its basically a name decoration issue, not resolved by linkers.

In VC++ 6.0 _cdecl is the default calling convention.

_cdecl In this type convention the caller is responsible for cleaning up the stack.
_stdcall In this type of convention the callee is responsible for cleaning up the stack.

search calling conventions.

Ancient Dragon commented: Thanks for the correction. +25

[quote=Narue;324080]You're making a series of nested boxes. The reason you failed is because you're trying to do it all at once, probably with no prior experience solving this kind of problem. So what you need to do is simplify it down to something that you can solve. For example, create a single filled box:
[code]
N: 4

1111111
1111111
1111111
1111111
1111111
1111111
1111111
[/code]
Now draw it empty:
[code]
N: 4

1111111
1 1
1 1
1 1
1 1
1 1
1111111
[/code]
The key element is that N designates a cross down the center of the box:
[code]
111111
111
111
111*111

111111
111
111
111*111
[/code]
You count up to N and then back down to 0. Once you understand and can implement all of this, try looking for patterns between the first row/column and the central row/column. That's where you come up with the final parts of the algorithm.

And no, I'm not going to tell you how to do it. It's important that you work through the process on your own. However, I can and will offer hints after you make some kind of attempt and show us your results.[/quote]

Thank you for such a nice description... friend i come up with a solution with a difference logic but still thank you for your help...

[code]

[COLOR=#008000]//**** for n=2;
[/COLOR][COLOR=#008000]/ 1 1 1
1 2 1
1 1 1
/
[/COLOR][COLOR=#008000]/***** for n=3 **
1 1 1 1 1
1 2 2 2 1
1 ...

[quote=darkAngel;321805]as above.
[code] string s;
cin >> s; [/code]
for example, if the user enters Orange, i want it to convert to orange.
please advise what i should do.

thanks in advance[/quote]

Check out this code
[code]
std::string str;
cin>>str;
transform(str.begin(), str.end(),str.begin(), tolower );
cout<< str;
[/code]

heyz it its undefined what about the following code
[code]

class A {
int a;
public:
A() : a ( 0 ) {}

int get() const {
cout <<" in A()" << endl;
return a;
}
};

int main()
{
((int)0x00100ff)=14;
cout<< reinterpret_cast<A*>(0x00100ff)->get() << endl;
return 0;
}
[/code]

it works ..........:)

please help me understand the folowing code....
[code]
class A {
int a;
public:
A() : a ( 0 ) {}
int get() {
cout << "Hello WOrld " << endl;
return 0;
}
};

int main( int argc, char* argv )
{
cout<< ((A
)3)->get() << endl;
return 0;
}
[/code]
this code runs! and prints the correct output if i return zero in get() function,, but when i return a it throws an exception ( i think becuase a is not initialized, infact not constructed ), but this code runs ......no idea:eek: