what target/platform to use

what target/platform to use

Post by Rob C » Tue, 07 Oct 2003 02:10:37


I copied this code out of a text book, but I didn work this
module into a project, but instead just compiled and ran it. It
runs fine.

But, now, when I attempt to work it into a project (Target type:
[Application], platform: [Win32]), I get a dialog box that
says, ou have accidentally used a dummy version of OwlMain.
Please, how can I fix this?

#includ<
#includ<

class Queue
{
int Q[100];
int sloc, rloc;
int who;

public:
Queue( int id );
~Queue();
void Qput( int i );
int Qget();
};

Queue::Queue( int id )
{
sloc=rloc = 0;
who = id;
cout<<< "Queue "<<< who<<< " intitialized\n\n";

}

Queue::~Queue()
{
cout<<< "Queue "<<< who<<< " destroyed \n\n";

}

void Queue::Qput( int i )
{
if( sloc == 100 )
{
cout<<< "Queue overflow";
return;
}
sloc++;
Q[sloc]=i;
}

int Queue::Qget()
{
if( rloc == sloc )
{
cout<<< "Queue overflow";
return 0;
}
rloc++;
return Q[rloc];
}

main()
{//44
Queue a(1), b(2);


a.Qput(10);
b.Qput(19);


a.Qput(20);
b.Qput(1);

cout<<< "Contents of Queue a & b : ";
cout<<< a.Qget()<<< " ";
cout<<< a.Qget()<<< " ";
cout<<< b.Qget()<<< " ";
cout<<< b.Qget()<<< " \n";

getch();

return 0;

}//44
 
 
 

what target/platform to use

Post by Ed Mulroy » Tue, 07 Oct 2003 03:24:11

When you created the project the TargetExpert dialog had settings for the
target type but also a checkbox for if you were using the Object Windows
Library, OWL. When you create an OWL program without the function OwlMain
(where OWL programs begin), it links in a routine from the library which
contains code to warn you of the mistake. That is what happened here.

A Win32 console mode program begins at the function main, and is a text mode
program just as you show.

Go to the project window and right click on the EXE file name.
Select TargetExpert from the window which appears
Set the platform and target type to Win32 Console

Afterwards do a Save All and a Project Build All

You might also want to check the date of that textbook. The function main
returns an int and C++ no longer assumes an int return type if no return
type is given. While the compiler is rigged to let you get away with it
because of the number of people maintaining legacy code, a book to learn
from really should reflect the level of the C++ language at least as new as
from 5 years ago.

. Ed