473,604 Members | 2,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

identifier expected,declar ation terminated incorrectly

1 New Member
i wrote this program.after compiling it gave this error.for more i'm writing the program.....

Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. class student
  3. {
  4. private:
  5. char name[20];
  6. int marks;
  7. public:
  8. void setinfo(void);
  9. void displayinfo(void);
  10. };
  11. void student::void setinfo(void)
  12. {
  13. cout<<"please enter ur name:";
  14. cin>>name;
  15. cout<<"please enter the marks:";
  16. cin>>marks;
  17. void student::void displayinfo(void)
  18. {
  19.   cout>>"Nmae=">>name;
  20.   cout>>"Marks=">>marks;
  21.   int main()
  22.   {
  23.     student stu1;
  24.     stu1.setinfo;
  25.     stu1.displayinfo;
  26.     exit(0);
  27.     }
  28.     }
  29.     }
error:identifie r expected
declaration terminated incorrectly
Sep 24 '12 #1
2 3700
Rabbit
12,516 Recognized Expert Moderator MVP
Please use code tags when posting code.

You didn't terminate your class methods correctly. They need to be terminated before you attempt to declare a different function.
Sep 24 '12 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
You have a variety of errors caused by inexperience. I went through the code and fixed the errors and I hope left enough comments so you can see what I did.

Expand|Select|Wrap|Line Numbers
  1. class student
  2. {
  3. private:
  4. char name[20];
  5. int marks;
  6. public:
  7. void setinfo(void);
  8. void displayinfo(void);
  9. };
  10. //void student::void setinfo(void)   /////<<<<
  11. void student::setinfo(void)
  12. {
  13. cout<<"please enter ur name:";
  14. cin>>name;
  15. cout<<"please enter the marks:";
  16. cin>>marks;
  17. }   //<<< added this brace
  18. //void student::void displayinfo(void)      //////<<<<<<
  19. void student::displayinfo(void)
  20. {
  21. //  cout>>"Nmae=">>name;            wrong
  22.  // cout>>"Marks=">>marks;           wrong
  23.      cout<<"Nmae="<<name;          //correct
  24.       cout<<"Marks="<<marks;       //correct
  25. }  //<<<< added this brace
  26.   int main()
  27.   {
  28.     student stu1;
  29.     //stu1.setinfo;          wrong
  30.     stu1.setinfo();         //corrected
  31.     //stu1.displayinfo;   wrong
  32.     stu1.displayinfo();
  33.     exit(0);
  34. }
  35.     //}  out of place          
  36.     //}  out of place
Sep 24 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
12879
by: Tony Tone | last post by:
I am having trouble resolving this issue: Server Error in '/test' Application. -------------------------------------------------------------------------------- Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
9
17370
by: Jack | last post by:
I get the following errors from the code ( CRM 3.0 ) below, whats wrong ? Any suggestions are welcome because i'm kinda stuck here. The first error is pointing on the last bracket ] <--- c:\inetpub\wwwroot\bredanaweb\jdshentlead.aspx.cs(18,35): error CS1001: Identifier expected
2
8772
by: jdziggy | last post by:
Hey all I am getting the compiler Identifier Expected on the following code. public partial class Form1 : Form { private const int MaxFiles = 10; private SourceFile m_sourceFiles(MaxFiles); private int m_files = 0; public Form1() {
3
1521
by: ana10192000 | last post by:
import java.util.Random; public class random_game { public static void main (String args) { int ctr,guess; Random r = new Random(); System.int.println(r.input.int(100)); int n = r.nextinput(100); System.out.print("Enter guess number: ");
4
44475
by: CodeTilYaDrop | last post by:
I am still pretty new to programming, and I sometimes can not figure something out. I am getting an error with this line in my program: Public void count_syllables(int count_syllables) I get the error <identifier expected>. What does this mean. I can not seem to make it go away!?
1
1929
by: Prat4u | last post by:
Hi I'm having <identifier> expected error when i compile the following code in the test application in java. Player player = new Player("Red Guy", Color.red, new Point(100,100), 0); player.setSpeed(10); player.setDirection(0); g.add(player); Ball ball = new Ball(new Point(100,100)); ball.setSpeed(10); ball.setDirection(0);
2
4433
by: camzgon121 | last post by:
Hi guys, I have this code and when I try to compile and run it gives me an <identifier> expected error. The code with the irrelevant parts taken out. package ACCOUNT; import java.util.Scanner; import java.util.GregorianCalendar; import javax.swing.*;
10
15753
by: preeya | last post by:
Hi, I have written the following program: ------------------------------------------------------------------------------------------------------------- 1 #include <stdio.h> 2 #include "abc.h" 3 4 void PROP_abc(double ptr)
3
3476
oll3i
by: oll3i | last post by:
package ejb; import javax.ejb.EJBObject; import java.rmi.RemoteException; import java.sql.Connection; import java.util.Map; public interface InterfaceRemote extends EJBObject { public Map <String,String> returnTable(String tableName) throws RemoteException; Connection getConnection()throws RemoteException; public int getNumberOfColumns(String tableName)throws RemoteException; }
2
7521
by: Chris Winton | last post by:
I am trying to do some matrix multiplication but i keep getting a expected declaration at the end of input. Any help would be much appreciated. /* Description:To multiply given to matrix using arrays*/ #include<stdio.h> #include<math.h> main() { int i,j,k; int a,b,c;/*three variables to get the row and colum of the two matrix*/ int sum;
0
7929
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8409
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8280
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5882
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3907
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.