error c2065

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • backen
    New Member
    • Dec 2009
    • 3

    #1

    error c2065

    Hi!
    i cant get this code to work, I get error c2065, undeclared identifier for some reason don´t really know why...
    this results in error C2146: syntax error : missing ';' before identifier 'Sorter'
    and error C2065: 'Sorter' : undeclared identifier....
    furthermore, I am not sure that my sorter will work (later problem =))
    And I hope here is a kind soul that can help me out =)

    the code:
    #include <iostream>
    #include <string>
    #include<cstdli b>
    using namespace std;

    int main(){
    ArraySorter Sorter; // <-- c2065





    return 0;
    }

    #pragma once
    #include<string >

    class ArraySorter
    {
    public:
    ArraySorter(voi d);
    void ISort(char *[], int );
    ~ArraySorter(vo id);
    private:

    };
    ------------------------------------------------------ArraySorter.cpp
    #include "ArraySorte r.h"
    #include<string >

    ArraySorter::Ar raySorter(void) {
    }
    void ArraySorter::IS ort(char* skivor[], int antalSkivor){

    int itr;
    for(int i=1;i<antalSkiv or;i++){
    //string name(skivor[i]);
    char *temp= skivor[i];
    itr=i-1;
    while(strcmp(sk ivor[itr], temp)>0 && itr>=0){
    skivor[itr+1]=skivor[itr];
    itr--;
    }
    skivor[itr+1]=temp;
    }

    }

    ArraySorter::~A rraySorter(void )
    {
    }
  • newb16
    Contributor
    • Jul 2008
    • 687

    #2
    you need to have this
    class ArraySorter
    {
    public:
    .....
    };

    included somewhere before you instantiate ArraySorter.
    #include "arraysorter.h" , most likely.

    Comment

    • backen
      New Member
      • Dec 2009
      • 3

      #3
      Hi!
      i have in ArraySorter. this;
      #pragma once
      #include<string >

      class ArraySorter
      {
      public:
      ArraySorter(voi d);
      void ISort(char *[], int );
      ~ArraySorter(vo id);
      private:

      };
      and I have
      #include "ArraySorte r.h"
      in ArraySorter.cpp .
      that is what you ment?

      Comment

      • manontheedge
        New Member
        • Oct 2006
        • 175

        #4
        #include <iostream>
        #include <string>
        #include<cstdli b>
        using namespace std;

        int main(){
        ArraySorter Sorter; // <-- c2065





        return 0;
        }
        you HAVE TO include the header in the file where you have 'main()' in order to use your class. Main() has no idea what you're doing without having the header for your class included.

        Comment

        • backen
          New Member
          • Dec 2009
          • 3

          #5
          aha!
          thanks, that solved it!

          Comment

          Working...