473,320 Members | 1,982 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,320 software developers and data experts.

identifier expected,declaration terminated incorrectly

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:identifier expected
declaration terminated incorrectly
Sep 24 '12 #1
2 3672
Rabbit
12,516 Expert Mod 8TB
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 Expert Mod 8TB
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
by: Tony Tone | last post by:
I am having trouble resolving this issue: Server Error in '/test' Application. -------------------------------------------------------------------------------- Compilation Error Description:...
9
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 ] <--- ...
2
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...
3
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...
4
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...
1
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); ...
2
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...
10
by: preeya | last post by:
Hi, I have written the following program: ------------------------------------------------------------------------------------------------------------- 1 #include <stdio.h> 2 #include...
3
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...
2
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...

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.