You can’t put the class declaration in the .cpp file. You have to put it in the .h file or else it’s not visible to the compiler. When main.cpp is compiled the type “first” is class first;
. That’s not useful at all because this does not tell anything to the compiler (like what size first is or what operations are valid on this type). Move this chunk:
class first { public: int a,b,c; int sum(int a , int b); };
from header1.cpp to header1.h and get rid of class first;
in header1.h
Related Posts:
- undefined reference to WinMain@16 (codeblocks)
- Why am I getting “undefined reference to main”
- Cannot open output file, permission denied
- template argument 1 is invalid (Code::Blocks Win Vista) – i don’t use templates
- How to create a dynamic array of integers
- How to implement 2D vector array?
- What is the difference between g++ and gcc?
- What is the best way to use a HashMap in C++?
- What is the difference between float and double?
- How do I find the length of an array?
- C++ — expected primary-expression before ‘ ‘
- Using getline() with file input in C++
- g++ ld: symbol(s) not found for architecture x86_64
- ‘g++’ is not recognized as an internal or external command, operable program or batch file
- How do I convert a double into a string in C++?
- How to create timer events using C++ 11?
- How to concatenate two strings in C++?
- ‘g++’ is not recognized as an internal or external command, operable program or batch file
- Read file line by line using ifstream in C++
- Virtual/pure virtual explained
- error: redefinition of class
- Officially, what is typename for?
- How do I iterate over the words of a string?
- C++ Vector of pointers
- error: lvalue required as unary & operand
- Why doesn’t C++ have a garbage collector?
- How does ifstream’s eof() work?
- terminate called after throwing an instance of ‘std::invalid_argument’ what(): stoi
- How to find memory leak in a C++ code/project?
- Error: C++ requires a type specifier for all declarations
- invalid use of non-static member function
- Cannot open include file: ‘stdio.h’ – Visual Studio Community 2017 – C++ Error
- srand(time(0)) and random number generation
- How to convert integer to double implicitly?
- How do I tokenize a string in C++?
- Reverse Contents in Array
- Why would we call cin.clear() and cin.ignore() after reading input?
- Should I learn C before learning C++?
- cin >> “no operator matches these operands”
- C++ on mac : linker command failed with exit code 1 (use -v to see invocation)
- Correct way to use cin.fail()
- Destructor for a linked List
- Why use a new call with a C++ ‘vector’?
- Identifier is undefined
- What are the most widely used C++ vector/matrix math/linear algebra libraries, and their cost and benefit tradeoffs?
- Insert object at index of vector c++
- Read whole ASCII file into C++ std::string
- Reading getline from cin into a stringstream (C++)
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?
- Delete 2D array C++
- class not declared in scope – even though .h was included
- Best C/C++ Network Library
- How to check that an element is in a std::set?
- Best way to extract a subvector from a vector?
- How do malloc() and free() work?
- Call to implicitly deleted copy constructor in LLVM
- C++ Linked List Node with class
- What is the use of intptr_t?
- why is string not declared in scope
- How does rhs work?
- error: expected unqualified-id before ‘.’ token //(struct)
- Base class undefined
- C++ – Assigning null to a std::string
- The program can’t start because libgcc_s_dw2-1.dll is missing
- C++ – Too Many Initializers for Arrays
- Reading string by char till end of line C/C++
- getline: identifier not found
- Colorizing text in the console with C++
- Show two digits after decimal point in c++
- error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
- gcc: undefined reference to
- C++ printing boolean, what is displayed?
- GCC -fPIC option
- initialize a vector to zeros C++/C++11
- “vector” was not declared in this scope
- Converting string to ASCII
- got “cannot appear in a constant-expression” when using template
- C++ ostream and ofstream conversions
- C++ discards qualifiers
- too many initializers for ‘int [0]’ c++
- function does not take 1 arguments c++
- overloaded function with no contextual type information
- How exactly do lookup tables work and how to implement them?
- Vector declaration “expected parameter declarator”
- C++ Destructors with Vectors, Pointers,
- error C2065: ‘cout’ : undeclared identifier
- How to get the MD5 hash of a file in C++?
- C++ Error: Expected a type specifier
- Where to declare/define class scope constants in C++?
- Friend methods error
- Does WPF Work with C++?
- Multiple inputs on one line
- Where can I find ‘winmm.lib’ (I’m using Visual Studio 2012)
- What is a `char*`?
- Does static constexpr variable inside a function make sense?
- “Incomplete type not allowed ” when creating std::ofstream objects
- Compiler error C4430: missing type specifier – int assumed [duplicate]
- ‘&’ : illegal operation on bound member function expression [duplicate]
- Multiple definitions of “Main”
- Getting the error floating point exception: 8