The function definition in .cpp file should be compatible with its decleration in .h file so modify it as follows.

.cpp file:

#include"testclass.h"
Car& testclass::createCar(int x, int y)
{
  ....
}

Note that I modified <testclass.h> to "testclass.h". use the brackets only with the built in headers.

Follow the following line if you want to know why you should use "testclass.h" instead of <testclass.h> and which one of them you should use Link

Answer from asmmo on Stack Overflow
🌐
cppreference.com
en.cppreference.com › cpp › headers
C++ Standard Library headers - cppreference.com
April 26, 2025 - Source files that are not intended to also be valid ISO C should not use any of the C headers. With the exception of complex.h, each xxx.h header included in the C++ standard library places in the global namespace each name that the corresponding cxxx header would have placed in the std namespace. These headers are allowed to also declare the same names in the std namespace, and the corresponding cxxx headers are allowed to also declare the same names in the global namespace: including <cstdlib> definitely provides std::malloc and may also provide ::malloc.
🌐
Lsu
ld2014.scusa.lsu.edu › cppreference › en › cpp › header.html
C++ Standard Library header files - cppreference.com
From cppreference.com · < cpp · C++ Standard Library header files · The interface of C++ standard library is defined by the following collection of header files.
Discussions

Why are we still dealing with header files?
A couple of weeks ago, I merged C++23's P2465R3 Standard Library Modules into microsoft/STL's main branch, which will ship in VS 2022 17.5 Preview 1. Compiler work to fix various ICEs is still ongoing, and build system work is still necessary, but the library work is done. The PR was microsoft/STL#3108 , which begins with: "I've added over 3,750 occurrences of _EXPORT_STD after auditing over 148,000 lines of headers." (That's my STL-internal macro that expands to export, not for users to use directly.) You can try this right now with the VS 2022 17.4 Preview 2 compiler, by building microsoft/STL main. Here's a quick example comparing #include to import std;: D:\GitHub\STL\out\build\x64>type paleolithic_era.cpp #include int main() { std::cout << "Goodbye, header world!\n"; } D:\GitHub\STL\out\build\x64>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od /Bt paleolithic_era.cpp paleolithic_era.cpp time(C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.34.31823\bin\HostX64\x64\c1xx.dll)=0.513s time(C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.34.31823\bin\HostX64\x64\c2.dll)=0.010s [...linker timings omitted for brevity...] D:\GitHub\STL\out\build\x64>paleolithic_era Goodbye, header world! D:\GitHub\STL\out\build\x64>type new_world_order.cpp import std; int main() { std::cout << "Hello, modules world!\n"; } D:\GitHub\STL\out\build\x64>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od /Bt /c D:\GitHub\STL\out\build\x64\out\modules\std.ixx std.ixx time(C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.34.31823\bin\HostX64\x64\c1xx.dll)=2.564s time(C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.34.31823\bin\HostX64\x64\c2.dll)=0.204s D:\GitHub\STL\out\build\x64>dir std.ifc std.obj | grep -P "\.ifc|\.obj" 10/10/2022 05:31 PM 28,156,007 std.ifc 10/10/2022 05:31 PM 7,211,607 std.obj D:\GitHub\STL\out\build\x64>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od /Bt new_world_order.cpp std.obj new_world_order.cpp time(C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.34.31823\bin\HostX64\x64\c1xx.dll)=0.131s time(C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.34.31823\bin\HostX64\x64\c2.dll)=0.006s [...linker timings omitted for brevity...] D:\GitHub\STL\out\build\x64>new_world_order Hello, modules world! What this shows (as a very quick and dirty benchmark, no attempt to run repeatedly and average timings) is: #include followed by Hello World usage of cout takes 513 ms of compiler front-end time (on my 5950X machine). Building the entire C++ Standard Library into a named module, which needs to be done only once for a given compiler toolset version and project command line, takes 2,564 ms of front-end time (and another 204 ms of back-end time for codegen; this is non-optimized debug mode). This is slightly slower than building a PCH (not depicted here), but not by much. import std; followed by Hello World cout takes only 131 ms of compiler front-end time. That is, importing the entire C++ Standard Library as a named module is 3.9x faster (times, not percent) than classic inclusion of . This speedup will naturally vary depending on what a real program is doing (including more headers will make the classic inclusion scenario much slower - is big but not the biggest - while doing more actual work in the source file will dilute the raw performance difference), but I think this effectively shows how simple (one import!) and fast the Standard Library Modules will be. There are other advantages (macro immunity, not leaking internal names) too. Finally, note that this is very space-efficient - the digested IFC file that allows this rapid importation is only 26.9 MB, plus another 6.9 MB for the OBJ - in previous measurements I've seen that this is about 10x smaller than a PCH. More on reddit.com
🌐 r/cpp
61
17
October 11, 2022
Is there a version of C++ STL with well documented header files ?
The libstdc++ one is passable. For instance here is the doc of std::copy : /** * @brief Copy the elements of a sequence for which a predicate is true. * @ingroup mutating_algorithms * @param __first An input iterator. * @param __last An input iterator. * @param __result An output iterator. * @param __pred A predicate. * @return An iterator designating the end of the resulting sequence. * * Copies each element in the range @p [__first,__last) for which * @p __pred returns true to the range beginning at @p __result. * * copy_if() is stable, so the relative order of elements that are * copied is unchanged. */ More on reddit.com
🌐 r/cpp
17
43
November 29, 2016
🌐
cppreference.com
en.cppreference.com › c › header
C Standard Library headers - cppreference.com
4.1.2 Standard headers · Categories: Pages using deprecated source tags · Pages using deprecated enclose attributes · Support us · Recent changes · FAQ · Offline version · What links here · Related changes · Upload file · Special pages · Printable version ·
🌐
SACO Evaluator
saco-evaluator.org.za › docs › cppreference › en › cpp › header.html
C++ Standard Library header files - cppreference.com
From cppreference.com · < cpp · C++ Standard Library header files · The interface of C++ standard library is defined by the following collection of header files · For some of the C standard library headers of the form xxx.h, the C++ standard library both includes an identically-named header and another header of the form cxxx (all meaningful cxxx headers are listed above).
🌐
University of Chicago
naipc.uchicago.edu › 2014 › ref › cppreference › en › cpp › header.html
C++ Standard Library header files - cppreference.com
From cppreference.com · < cpp · C++ Standard Library header files · The interface of C++ standard library is defined by the following collection of header files.
🌐
Cplusplus
cplusplus.com › reference
Standard C++ Library reference
Provides functionality to use an abstraction called streams specially designed to perform input and output operations on sequences of character, like files or strings. This functionality is provided through several related classes, as shown in the following relationship map, with the corresponding ...
🌐
Lsu
ld2014.scusa.lsu.edu › cppreference › en › c › header.html
C Standard Library header files - cppreference.com
C Standard Library header files · From cppreference.com · [edit] See also · Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/header&oldid=71951"
Find elsewhere
🌐
Patrickfasano
cppreference.patrickfasano.com › en › c › header.html
C Standard Library header files - cppreference.com
From cppreference.com · < c · C · The interface of C standard library is defined by the following collection of headers.
🌐
Dpvipracollege
dpvipracollege.ac.in › wp-content › uploads › 2023 › 01 › C-Plus-Plus-The-Complete-Reference-3rd-Ed.pdf pdf
C++: The Complete Reference Third Edition
The Form of a C Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... The Library and Linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... Understanding the .C and .CPP File Extensions . . . . . . . .
🌐
IBM
ibm.com › docs › en › xl-c-and-cpp-aix › 13.1.0
Standard C++ Library Header Files - IBM Documentation
March 5, 2021 - The name of each of these C++ headers is of the form cname, where name is the string that results when the “.h” extension is removed from the name of the equivalent C Standard Library header. For example, the header files <stdlib.h> and <cstdlib> are both provided by the C++ Standard Library and are equivalent in function, with the exception that all declarations in <cstdlib> are located within the std namespace.
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › cpp › header-files-cpp
Header files (C++) | Microsoft Learn
We add an #include directive for "my_class.h" file in order to have the my_class declaration inserted at this point in the .cpp file, and we include <iostream> to pull in the declaration for std::cout. Note that quotes are used for header files in the same directory as the source file, and angle brackets are used for standard library headers.
🌐
Cppreference
en.cppreference.com › w › cpp › header › new.html
Standard library header <new> - cppreference.com
April 12, 2024 - namespace std { class bad_array_new_length : public bad_alloc { public: // see description for the specification of the special member functions constexpr const char* what() const noexcept override; }; } Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/header/new&oldid=170819" Support us · Recent changes · FAQ · Offline version · What links here · Related changes · Upload file ·
🌐
Raquent
raquent.in › posts › answering-whats-your-favorite-cpp-feature
Answering "what's your favorite C++ feature" - Raquent.in
February 16, 2025 - constexpr inline std::string ParserError::get_brief() const { return std::visit( [](auto &&arg) { using T = std::decay_t<decltype(arg)>; if constexpr (std::is_same_v<T, MalformedSectionHeader>) return "malformed section header"; else if constexpr (std::is_same_v<T, ExpectedColonInHeaderAssignment>) return "missing colon in header assignment"; }, info_); } See also: constexpr virtual functions from C++20. std::optional is quite nice for handling nullish yet non-error states.
🌐
Cppreference
en.cppreference.com › w › cpp › header › utility.html
Standard library header <utility> - cppreference.com
November 24, 2024 - This header is part of the general utility library. #include <compare> #include <initializer_list> namespace std { // swap template<class T> constexpr void swap(T& a, T& b) noexcept(/* see description */); template<class T, size_t N> constexpr void swap(T (&a)[N], T (&b)[N]) noexcept(is_nothrow_swappable_v<T>); // exchange template<class T, class U = T> constexpr T exchange(T& obj, U&& new_val); // forward/move template<class T> constexpr T&& forward(remove_reference_t<T>& t) noexcept; template<class T> constexpr T&& forward(remove_reference_t<T>&& t) noexcept; template<class T, class U> const
🌐
cppreference.com
en.cppreference.com › cpp › header › filesystem
Standard library header <filesystem> (C++17) - cppreference.com
November 27, 2023 - namespace std::filesystem { class path { public: using value_type = /* see description */; using string_type = basic_string<value_type>; static constexpr value_type preferred_separator = /* see description */; // enumeration format enum format; // constructors and destructor path() noexcept; path(const path& p); path(path&& p) noexcept; path(string_type&& source, format fmt = auto_format); template<class Source> path(const Source& source, format fmt = auto_format); template<class InputIt> path(InputIt first, InputIt last, format fmt = auto_format); template<class Source> path(const Source& sou
🌐
Cppreference
en.cppreference.com › w › cpp › header › cctype.html
Standard library header <cctype> - cppreference.com
February 1, 2025 - This header was originally in the C standard library as <ctype.h>.