Improper use of typedef

This is a discussion on Improper use of typedef within the C++ Programming forums, part of the General Programming Boards category; Anyone knows what does these errors mean ? Error E2108 workingArea.cpp 61: Improper use of typedef 'string' in function newCode() ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    58

    Improper use of typedef

    Anyone knows what does these errors mean ?


    Error E2108 workingArea.cpp 61: Improper use of typedef 'string' in function newCode()
    Error E2121 workingArea.cpp 61: Function call missing ) in function newCode()
    *** 2 errors in Compile ***

    Code:
    int main()
    {
    	string billy [12];
    	int tester;
    		while((tester >= 1) || (tester < 4))
    		{
    			cout << "select one of these options\n";
     			cout << "(1) Insert a new code\n";
     			cout << "(2) Print the data\n";
    			cout << "(3) Program requirments\n";
    			cout << "(4) Exit the program\n";
    
    			cin >> tester;
    			
    			if(tester==1)
    				newCode();		
    			else if (tester==2)
    				printCode();
    		 	else if (tester==3)
    				errorCode();	
    			else if (tester==4)
    				break;
    			else
    				cout << "ERROR!!! You must choose one of the options from 1 to 4";
    		}
    return 0;
    
    }  
    
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    void newCode()
    {
    	string serial_number;
    	int length;	
       	
       cout<< "please enter a serial number of 12 characters:";
    	cin >> serial_number;
    	length = serial_number.length();
    	
    	std::string mystr = serial_number;
    
    	if (length!=12 )
    		cout << "There must be 12 characters exactly";
    	else 
    		 checkOne(string serial_number);
    
    }
    
    void checkOne(	string serial_number)
    {
    	std::string mystr = serial_number;
    	for( int i=0; i<13;i++)
    	{
    		if( mystr[i]!= '4')
    			break;
    			cout << "correct"<<endl;
    	}
    		
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,672
    > checkOne(string serial_number);
    Your call is wrong.
    Remove the type.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    58
    I deleted the type but a bunch of errors showed up are the following:

    Error E2268 workingArea.cpp 61: Call to undefined function 'checkOne' in function newCode()
    Warning W8054 workingArea.cpp 65: Style of function definition is now obsolete
    Error E2238 workingArea.cpp 67: Multiple declaration for 'serial_number' in function checkOne()
    Warning W8057 workingArea.cpp 76: Parameter 'serial_number' is never used in function checkOne()
    *** 2 errors in Compile ***


    All what I want to do is to use the ( serial_number) and the ( mystr) in the (void checkOne()) method from the ( void newCode()) method. This is also the first part that I did not post:

    Code:
    #include <iostream>
    #include <cctype>
    #include<string>
    #include <stdio.h>
    #include <stdlib.h>
    using namespace std;
    
    void newCode();
    void printCode();
    void errorCode();
    //void checkOne();
    
    string billy [12];

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,672
    a) you need to prototype your functions
    b) you need to make sure the parameters match in the prototype and the definition.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 11:36 AM
  3. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 08:22 AM
  4. build errors migrated from dx9b to dx9c sdk
    By reanimated in forum Game Programming
    Replies: 4
    Last Post: 12-17-2004, 06:35 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 11:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21