473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

hi problem, with c++ code i am learn so plz tell me what i did worng and how fix

mm the code
//////makemenu.h////
class menu {

public:
int op;
pmenu(int op,int sub = 0)
{
switch op
{
case 1:
show(op,0);
break;
case 2:
show(op,0);
break;
case 3:
show(op,0);
break;
case 4:
show(op,0);
break;
default:
msgerr(01);
}
}
show (int op,int sub=0)
{
cont<<"ok"<<end1<<"u press : "<<op;
}
};
/////////menus.cpp//////
#ifndef __file__
#define __file__ "telcom.db"
#endif
#include <iostream.h>
#include <stdio.h>
#include <fstream.h>
#include "makemenu.h"
main {
menu p1;
char option;
int total=3,stot=9,op;
showstars(total,stot);
cont<<"Enter number 1-4"<<end1;
option = getchar();
p1.pmenu(option,0);
return(0);
}
showstars(int line,int chrs)
{
int i;
for (i=1;i<=line;i++)
{
if (i != 1)
{
cont<<end1<<setfill("*")<<setw(chrs);
}
else
{
cont<<setfill("*")<<setw(chrs);
}
}
cont<<end1;
return(1);
}
the errors:
--------------------Configuration: tt - Win32
Debug--------------------
Compiling...
menus.cpp
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(24)
: warning C4183: 'pmenu': member function definition looks like a
ctor, but name does not match enclosing class
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(28)
: warning C4183: 'show': member function definition looks like a ctor,
but name does not match enclosing class
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(8) :
error C2061: syntax error : identifier 'op'
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(8) :
error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(9) :
error C2046: illegal case
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(11)
: error C2043: illegal break
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(12)
: error C2046: illegal case
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(14)
: error C2043: illegal break
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(15)
: error C2046: illegal case
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(17)
: error C2043: illegal break
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(18)
: error C2046: illegal case
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(20)
: error C2043: illegal break
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(21)
: error C2047: illegal default
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(22)
: error C2065: 'msgerr' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(27)
: error C2065: 'cont' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(27)
: error C2297: '<<' : illegal, right operand has type 'char [3]'
c:\program files\microsoft visual studio\myprojects\tt\makemenu.h(27)
: error C2065: 'end1' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\tt\menus.cpp(8) :
error C2501: 'main' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\myprojects\tt\menus.cpp(8) :
error C2239: unexpected token '{' following declaration of 'main'
c:\program files\microsoft visual studio\myprojects\tt\menus.cpp(25) :
error C2065: 'setfill' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\tt\menus.cpp(25) :
error C2065: 'setw' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\tt\menus.cpp(25) :
warning C4552: '<<' : operator has no effect; expected operator with
side-effect
c:\program files\microsoft visual studio\myprojects\tt\menus.cpp(29) :
warning C4552: '<<' : operator has no effect; expected operator with
side-effect
c:\program files\microsoft visual studio\myprojects\tt\menus.cpp(32) :
warning C4552: '<<' : operator has no effect; expected operator with
side-effect
Error executing cl.exe.

menus.obj - 19 error(s), 5 warning(s)
===========================================
plz tell me how i can fix and know not to do next time i try but....
Jul 22 '05 #1
3 2924
fastwings wrote:
mm the code
//////makemenu.h////
class menu {

public:
int op;
pmenu(int op,int sub = 0)
Your function is missing a return type. Every function needs a return
type. If you don't want to return anything, use void. You should also
consider implementing your function not in the header, but a
separate .cpp file.
{
switch op
switch (op)
{
case 1:
show(op,0);
break;
case 2:
show(op,0);
break;
case 3:
show(op,0);
break;
case 4:
show(op,0);
break;
default:
msgerr(01);
Where is the function msgerr?
}
}
show (int op,int sub=0)
Again, return type missing.
{
cont<<"ok"<<end1<<"u press : "<<op;
'cont' is supposed to be 'cout' and the 'end1' should be 'endl'. Also,
you forgot to #include the header needed for them. So you need to add:

#include <iostream>

at the top. Also, it would be std::cout and std::endl.
}
};
/////////menus.cpp//////
#ifndef __file__
#define __file__ "telcom.db"
#endif
The above three lines look like they are supposed to be an include
guard, but are used wrong. First, they need to be in the header, not
the implementation file. Further, the #endif needs to be at the bottom
of the file, so that the #ifndef/#endif encloses the whole file.

#include <iostream.h>
#include <iostream>

The version with .h was never part of standard C++ and is outdated for
years and deprecated in some compilers.
#include <stdio.h>
#include <fstream.h>
#include <fstream>
#include "makemenu.h"
main {
Again, your function is missing a return type. For main that must be
int.
menu p1;
char option;
int total=3,stot=9,op;
showstars(total,stot);
showstars is not yet dechared here, so the compiler doesn't know it yet.
Either put the definition of that function before main, or add a
prototype before it.
cont<<"Enter number 1-4"<<end1;
Again, replace cont with std::cout and end1 with std::endl.
option = getchar();
p1.pmenu(option,0);
return(0);
}
showstars(int line,int chrs)
Return type missing again.
{
int i;
for (i=1;i<=line;i++)
{
if (i != 1)
{
cont<<end1<<setfill("*")<<setw(chrs);
}
else
{
cont<<setfill("*")<<setw(chrs);
}
}
cont<<end1;
return(1);
}
The rest shold be clear now.
plz tell me how i can fix and know not to do next time i try but....


Have you actually had a look at the program and the error messages
yourself? Some of the errors should be obvious, even for a beginner.

Jul 22 '05 #2
On 17 Apr 2004 13:44:38 -0700 in comp.lang.c++, sw******@intermail.co.il
(fastwings) wrote,
public:
int op;
pmenu(int op,int sub = 0)
{


You forgot to declare the return type of function pmenu.

Jul 22 '05 #3
fastwings writes:
mm the code
//////makemenu.h////
class menu {

public:
int op;
pmenu(int op,int sub = 0)
{
switch op
{
case 1:
show(op,0);
break;
case 2:
show(op,0);
break;
case 3:
show(op,0);
break;
case 4:
show(op,0);
break;
default:
msgerr(01);
}
}
show (int op,int sub=0)
{
cont<<"ok"<<end1<<"u press : "<<op;
cout?
}
};
/////////menus.cpp//////
#ifndef __file__
#define __file__ "telcom.db"
#endif
#include <iostream.h>
#include <stdio.h>
#include <fstream.h>
#include "makemenu.h"
main {
menu p1;
char option;
int total=3,stot=9,op;
showstars(total,stot);
cont<<"Enter number 1-4"<<end1;
cout?? endl as in 'ell'
option = getchar();
p1.pmenu(option,0);
return(0);
}
showstars(int line,int chrs)
{
int i;
for (i=1;i<=line;i++)
{
if (i != 1)
{
cont<<end1<<setfill("*")<<setw(chrs);
}
else
{
cont<<setfill("*")<<setw(chrs);
}
}
cont<<end1;
return(1);
}


I suppose there is a lot more too.
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

68
by: Marco Bubke | last post by:
Hi I have read some mail on the dev mailing list about PEP 318 and find the new Syntax really ugly. def foo(x, y): pass I call this foo(1, 2), this isn't really intuitive to me! Also I...
4
by: Yaron Cohen | last post by:
Hi, I would like to ask for you help. I have a page that contains few JS files (please see below). The problem is that sometimes one of the files is not loaded (I am using IE 5.5). I get...
1
by: Shweta Agnihotri | last post by:
I created a mock databse table caleld custifo. it has customer infformation like name, address etc. In visual studio.net, I created a form that would allow users to input the last name have all...
5
by: Raj Chudasama | last post by:
I have a client server app. On the client i have buttons (derived from user contol) that let user perform actions when they are connected to the server. so when they connect (using a menuitem) i...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
8
by: sara | last post by:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report. Then it seems I still get the 2501 message on the Open Report...
31
by: anand devarajan | last post by:
hi friends, im anand im just a beginner in c learning for the past two weeksnow i can write simple prgs can anyone help me to get well known to c lang so that i should able to write even tough...
27
by: comp.lang.tcl | last post by:
My TCL proc, XML_GET_ALL_ELEMENT_ATTRS, is supposed to convert an XML file into a TCL list as follows: attr1 {val1} attr2 {val2} ... attrN {valN} This is the TCL code that does this: set...
2
by: shomun | last post by:
Hi, I am new to regular expression stuffs. I am facing problem while implementing a reg. exp. for a textbox using regular expression validator in ASP page. Requirement: It will take only...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.