Results 1 to 6 of 6

Thread: "Error 303" in program

  1. #1
    Join Date
    Jan 2010
    Posts
    119

    "Error 303" in program

    Hello,
    I have a problem with my C + + program. I get the following messages when I try to compile it:
    Code:
    error: stray '\ 303' in program |
    Do you have an idea about this error. I searched on internet but was not able to find a good solution. Thank you.

  2. #2
    Join Date
    Mar 2010
    Posts
    197

    Re: "Error 303" in program

    Try the following code

    Code:
    # Include <string>
    
    using namespace std;
    
    template <>
    unsigned int data<class T>::find(string ky)
    (
        for (int i=0; i<(sizeof(ky) /sizeof(ky[0])); i+ +)
        (
            unsigned int p = ky[i].find(ky)
            if (p! =0)
            (
                return (p);
            )
        );
    );

  3. #3
    Join Date
    Nov 2009
    Posts
    446

    Re: "Error 303" in program

    As for the stray error: are not allowed in the code. N there are still some other errors: In your program it must std:: string name instead of string, and arrays in C + +, you can not declare the way you do that. (String ky []) The length must be given more, unless it is initialized directly from the declaration. If you still do not know the size, matches dynamically [with new] or equal to n rather use std:: vector. Your constructor and destructor is missing the way to implementation. If they are to do nothing, let them just completely gone. Which are then automatically generated by the compiler. At the end of the class definition of data is missing besides the semicolon.

    The definition
    Code:
    template <> unsigned int data <class T>:: find (string key) (//...)
    is wrong, should look like this:
    Code:
    template <class T> unsigned int data <T>:: find (string key) (//...)

  4. #4
    Join Date
    Dec 2009
    Posts
    204

    Re: "Error 303" in program

    Alternatively you can include this in your code

    Code:
    # Include <iostream> 
    # Include <string> 
    using namespace std; 
    
    int main() 
    ( 
        datastruct<string> ar [2] = (("asdfg", "sdgf"), ("xre", "afd")); 
        data<string> ts(sizeof(ar) /sizeof(ar [0]), ar); 
        court<<ts.find("h"); 
    )

  5. #5
    Join Date
    Dec 2009
    Posts
    192

    Re: "Error 303" in program

    Just do not turn thought with templates. Where the separation of header and source is not possible (=> pack the complete source in the header file). The reasons I'll Spare time, it requires skills in compiler halfway. By the way, your destructor is wrong. delete dataset is undefined behavior that dataset must be delete [] released because of the memory with new [] was requested.
    Code:
    ~ Data () (delete] dataset [;)
    And do not forget to implement copy constructor and assignment operator, otherwise you're risking slightly nervous to delete duplicate copies. Or you take as I have already suggested earlier std:: vector, then you need not worry at all drum. Here even with the looks as you would recreate what is there already.

  6. #6
    Join Date
    Mar 2010
    Posts
    197

    Re: "Error 303" in program

    Here is the code you can try


    Code:
    / / Data.h 
    # Include <string> 
    
    template<class T> 
    datastruct struct 
    ( 
        std::string key; 
        T content; 
    ); 
    
    template <class T> 
    class data 
    ( 
        private: 
            datastruct<T> *dataset; 
        public: 
            data(unsigned int num, datastruct<T> *); 
            ~Data(); 
            int find(std::string schluessel); 
            T operator[] (unsigned int pos); 
    );

Similar Threads

  1. Replies: 3
    Last Post: 19-03-2012, 09:47 AM
  2. Replies: 6
    Last Post: 07-07-2011, 09:47 PM
  3. Replies: 8
    Last Post: 17-05-2011, 11:02 PM
  4. C-compiler gives "Abnormal program termination" error message
    By Linoo in forum Software Development
    Replies: 4
    Last Post: 11-02-2010, 08:36 PM
  5. Replies: 1
    Last Post: 17-01-2008, 08:37 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,931,369.42434 seconds with 17 queries