|
From: Vatay <va...@op...> - 2001-10-23 12:39:25
|
Hi,
I have one litle problem, to this time only C projects written and slowly
become familiar with polimorfizm and here is my problem:
I can't asking my friends (all programmed in Delphi).
A have one litte example written and the compiler returned 7 errors!
what have I wrong written?
Thank,
Szeg=82ny Leg=82ny
Error message:
c:/devcpp/paramtr/main.cpp: In function `int main()':
c:/devcpp/paramtr/main.cpp:11: `int_count' undeclared (first use this
function)
c:/devcpp/paramtr/main.cpp:11: (Each undeclared identifier is reported only
once
c:/devcpp/paramtr/main.cpp:11: for each function it appears in.)
c:/devcpp/paramtr/main.cpp:11: parse error before `;'
c:/devcpp/paramtr/main.cpp:12: `float_counter' undeclared (first use this
function)
c:/devcpp/paramtr/main.cpp:14: `c1' undeclared (first use this function)
c:/devcpp/paramtr/main.cpp:15: `c2' undeclared (first use this function)
Sorce code's:
// FILE: main.cpp
//
// SNIP: parametrikus polimorfizmus
#include <stdio.h>
#include "count.h"
main()
{
int_count c1;
float_counter c2;
c1.put_value(5);
c2.put_value(5.5);
printf("\n c1 =3D %d", c1.access_value() );
printf("\n c2 =3D %f", c2.access_value() );
}
// FILE: count.h
template <class T> class counter
{
private:
T value;
public:
counter () { value =3D 0; }
void increment() { value++; }
void decrement() { if(value > 0) value--; }
T access_value() { return value; }
void put_value( T new_value) { value =3D new_value; }
};
counter<int> int_counter;
counter<float> float_counter;
----------------- Live long OPREA & the Net
This e-mail has been sent with OperaMail, as a free service from
Opera Software.
|