Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why I cant to expand a function?

Status
Not open for further replies.

rick05

Programmer
Feb 23, 2001
15
MX

Hi again guys, (and thanks matt for answerme, I´ll to probe it and later I´ll say you)....

I have another trouble....

in the next program, my method "reserva" doesn´t make nothing!!

I wonder if u know why....

thanks again.

rick

----------------------------

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <iostream.h>
#include <fstream.h>
#include <conio.h>


struct part
{
float v1, v2;
};

struct hoyo
{
float v1,v2,v3;
};

template <class T> class base
{
public:
T *vector;
T **vector2;
T *cadena;
base ()
{

};
void Poner()
{

}
void Imprimir()
{

};
};

template <class T>
class derivada_part:public base<T>
{
public:

part valores;
// T *vector;

derivada_part(part vals)
{
// vector = new (other)T;

valores.v1=vals.v1;
valores.v2=vals.v2;

};
void Imprimir()
{
cout << &quot;esta marinola es para probar... valores de particula&quot;
<< &quot;\nvalores &quot; << valores.v1 << &quot;,&quot; << valores.v2;

};
void reserva () {}

};

// the next function doesn´t work :-(

template <class T> void derivada_part<T>::reserva()
{

cout << &quot;\naqui si entro...!!!!!\n&quot;;
};

template <class T>
class derivada_hoyo:public base <T>
{
public:
hoyo valores;
T *vector;
derivada_hoyo(hoyo vals)
{
valores.v1=vals.v1;
valores.v2=vals.v2;
valores.v3=vals.v3;
};
void Imprimir()
{
cout << &quot;\nesta marinola es para probar... valores de hoyo&quot;
<< &quot;\nvalores &quot; << valores.v1 << &quot;,&quot; << valores.v2 << &quot;,&quot;
<< valores.v3;
};

}


void main (void)
{

part temparti;

hoyo temphoyo;

derivada_part <void> *ptr_obj;


clrscr();

cout << &quot;ejemplo de las clases de templates&quot; << endl << endl;

// clases

temparti.v1=1.5;
temparti.v2=2.5;

temphoyo.v1=4.5;
temphoyo.v2=4.5;
temphoyo.v3=4.5;

derivada_part <part> term_part1(temparti); //crea el objeto particula...
term_part1.Imprimir();
term_part1.reserva();
term_part1.reserva();
term_part1.reserva();

derivada_hoyo <hoyo> term_hoyo1(temphoyo);
term_hoyo1.Imprimir();

getch();
}


 
You inlined the function. Remove the {} in the class declaration. This also suggest to me that you did not declare the function properly as you should have seen some sort of multiple declaration error.

Matt
 

Hi!

this trouble is already resolved... thanks to matt...

but my trouble with dinamic memory and class not yet...

anybody can helpme, please?

rick
 
What is the problem you are having? Are you trying to use dynamic memory in a class? If so, your destructor needs to methodically go through all the dynamic memory and free it or you will have memory leaks. Post the specifics of the problem and I will see if I can help.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top