Thread: expected unqualified-id before '{' token...

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    2

    expected unqualified-id before '{' token...

    Code:
    #include"spisak.hpp"
    void Evidencija::insertPoruka() {
    
    
     Poruka po;
     char p[100];
     cout<<"Unesite za :"<<endl;
     cin>>p;
     po.setZa(p);
     cout<<"Unesite od koga: "<<endl;
     cin>>p;
     po.setOd(p);
     cout<<"Unestie text: "<<endl;
     cin>>p;
     po.setText(p);
     cout<<"***********************************************";
     cout<<endl;
    
    
     cout<<po<<endl;
     cout<<"************************************************";
     cout<<endl;
     primljeno.add(1,po);
    
    
    
    
    
    
    }
    { //--------------26 line
    
    
     Poruka po;
     char p[100];
     cout<<"Unesite za :"<<endl;
     cin>>p;
     po.setZa(p);
     cout<<"Unesite od koga: "<<endl;
     cin>>p;
     po.setOd(p);
     cout<<"Unestie text: "<<endl;
     cin>>p;
     po.setText(p);
     cout<<"***********************************************";
     cout<<endl;
    
    
     cout<<po<<endl;
     cout<<"************************************************";
     cout<<endl;
     poslato.add(1,po);
    
    
    
    
    }
    void Evidencija::printSpisak() const {
    cout<<"-----------------EVIDENCIJA PORUKA--------------- ";
    cout<<endl;
    Poruka po;
    for( int i=1;i<primljeno.size();i++){
    primljeno.read(i,po);
    cout<<po<<endl;
    }
    cout<<"--------------------------------------------------";
    cout<<endl;
    
    
    }
    
    
    
    
    void Evidencija::printSpisak1() const {
    cout<<"-----------------EVIDENCIJA PORUKA--------------- ";
    cout<<endl;
    Poruka po;
    for( int i=1;i<poslato.size();i++){
    poslato.read(i,po);
    cout<<po<<endl;
    }
    cout<<"--------------------------------------------------";
    cout<<endl;
    
    
    }
    and error is on line 26

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Since the previous line is the closing brace for the previous function, I guess you missed out the function name, return type, parameters etc.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    It might help for you to explain what you think the purpose of that line is, and the one before it. Then we can perhaps see where you are going wrong with your thinking.

    You should also work on fixing your indentation because that will hilight most of these kind of problems.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    >> char p[100];
    >> cout<<"Unesite za :"<<endl;
    >> cin>>p;
    Never do that.
    If you are going to read a string, use std::string:
    std::string p;
    cout<<"Unesite za :"<<endl;
    cin>>p;
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Dec 2012
    Posts
    2
    Very stupid mistae,here in 26. line u forgot to put
    Code:
    void Evidencija::insertPoruka()
    .... Tnx all for help

    Code:
    >> char p[100];
    >> cout<<"Unesite za :"<<endl;
    >> cin>>p;
    Never do that.
    If you are going to read a string, use std::string:
    std::string p;
    cout<<"Unesite za :"<<endl;
    cin>>p;
    Tnx for the advce i change it now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. expected ) before ; token
    By dwolf559 in forum C Programming
    Replies: 2
    Last Post: 10-03-2012, 11:06 PM
  2. expected expression before ')' token
    By m_programmer in forum C Programming
    Replies: 6
    Last Post: 09-14-2012, 08:02 AM
  3. error: expected unqualified-id before '{' token
    By fhbwghads in forum C++ Programming
    Replies: 5
    Last Post: 12-25-2008, 04:39 AM
  4. error: expected unqualified-id before '=' token
    By (::) in forum C++ Programming
    Replies: 2
    Last Post: 05-16-2008, 11:50 PM
  5. Error: expected unqualified-id before 'using'
    By g4j31a5 in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2006, 05:24 AM