TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: DANIEL MCGREGOR
from: JAN BIJSTERBOSCH
date: 1997-05-12 20:50:00
subject: Struct vs. class

Hello Daniel,
On May 08, 97, Daniel McGregor of 1:140/237.2 wrote to Jerry Coffin
 DM> Hello Jerry!
DM>> The last I checked in my compiler (Turbo C++ 3.1) "struct"
DM>> wouldn't let you use member functions while class would.
 DM> Its the compilers bug.  And I lied, its TC++ 3.0.
Hmm, I won't say you're lying again ;-)) but a struct with TC++ 3.0 for Dos 
works perfectly well in C++, hence the following code:
// structst.cpp  Remember to use the cpp extension otherwise some Borland 
// compilers will think its plain ol' 'C'
#include 
struct OpenClass {
    int x, y;
    OpenClass(int X, int Y) : x(X), y(Y) { }
    ~OpenClass() { }
    void print();
};
void OpenClass::print()
{
    printf("\nNumbers in struct: %d, %d\n", x, y);
}
int main()
{
    OpenClass t(10,20);
    t.print();
    return 0;
}
// end of example **********************
This works, as said, perfectly well in TC++ 3.0 for Dos here in Amsterdam. 
Perhaps that that has something to do with it...
 DM> Daniel
CU on screen, Jan
email: bijster@worldonline.nl
http://www.worldonline.nl/~bijster
--- MBM v3.41e
---------------
* Origin: Snuffelaar bij DosBoss West (2:500/121.5122)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.