#ifndef SEARCHING_H
#define SEARCHING_H
#include "Assignments.cpp"
class searching {
public:
searching();
int menu();
int searchClass(task tasks[], int num, int searchedTasks[]); //Searches by Class
int searchAssign(task tasks[], int num, int searchedTasks[]); //Searches by Assignment
void displaySearch(task tasks[], int searchedTasks, int num);
private:
int choice;
int count;
char searchName[100];
};
#endif
Ok.... I tried that but it still says 'Undeclared Identifier!' I even tried putting the object declaration outside of the switch statement, but the error is still there.
That's goofy. I do believe that the brackets are necessary when declaring variables within a case so you'll need that eventually. I'm always skeptical when someone does a partial copy and paste as you have done. It makes me wonder if I am really looking at exactly what you are trying to compile. Is there a typo in the file name for the header class? Is the compiler really finding the header file at all? I would start looking for silly mistakes like that.
Hi guys, I've been having the same problem for a while now. I'm pretty sure the problem is with visual c++ because I've made several alterations to my code with no luck, and I tried writing a very simple program to see whether I could declare an object and it still giving me the 'undeclared identifier' error.
I also copied the code to a linux computer using codeblocks and the same code ran fine.
#ifndef DATE_H
#define DATE_H
class Date
{
private:
int m_nMonth;
int m_nDay;
int m_nYear;
Date() { }
public:
Date(int nMonth, int nDay, int nYear);
void SetDate(int nMonth, int nDay, int nYear);
int GetMonth() { return m_nMonth; }
int GetDay() { return m_nDay; }
int GetYear() { return m_nYear; }
};
#endif
Source file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include "Date.h"
usingnamespace std;
Date::Date(int nMonth, int nDay, int nYear)
{
SetDate(nMonth, nDay, nYear);
}
void Date::SetDate(int nMonth, int nDay, int nYear)
{
m_nMonth = nMonth;
m_nDay = nDay;
m_nYear = nYear;
}
Main
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include "Date.h"
usingnamespace std;
int main()
{
Date date; //Everything is fine untill this point
//this is when I get the undeclared identifier error
return 0;
}