header-files

Automatically split (refactor) .h into header and implementation (h+cpp)

拜拜、爱过 提交于 2020-06-08 03:39:07
问题 When writing C++ code, I often start by writing full 'implementation' code in my header files, then later need to refactor the implementation into a .cpp file. This is great, but I find this process laborious, but otherwise pretty easy, so I wondered about whether is there any automated way to do this? Specifically, I want to convert all class and function definitions in the .h to declarations, and have them declared in a new .cpp file. I'm using xcode, but I am open to any solutions. 回答1:

C++ error: Variable does not name a type when attemtping to access global variables

为君一笑 提交于 2020-04-30 07:05:17
问题 Within a program i am writing i have 3 files. main, functions and a header file. The main file makes use of the header #include "implementation.cpp", and the function file makes use of the header #include "driver.h". Within the implementation file 3 structs have been declared, each sharing their values through the use of extern, too be seen in the minimal reproducing code required. Within the header file i have declared 3 variables to use these extern variables. I believed this was enough to

C++ error: Variable does not name a type when attemtping to access global variables

爷,独闯天下 提交于 2020-04-30 07:04:25
问题 Within a program i am writing i have 3 files. main, functions and a header file. The main file makes use of the header #include "implementation.cpp", and the function file makes use of the header #include "driver.h". Within the implementation file 3 structs have been declared, each sharing their values through the use of extern, too be seen in the minimal reproducing code required. Within the header file i have declared 3 variables to use these extern variables. I believed this was enough to

Are there advantages of using const member variable in C++

陌路散爱 提交于 2020-04-11 04:20:09
问题 I write code like template <typename XAxis, typename YAxis> class Interpolation { public: using x_value_type = typename XAxis::value_type; using y_value_type = typename YAxis::value_type; Interpolation(const XAxis& x_axis, const YAxis& y_axis) : _x_axis(x_axis), _y_axis(_y_axis) {} public: y_value_type interpolate(const x_value_type& x) const; private: const XAxis _x_axis; const XAxis _y_axis; }; when i want to intent that member variables is immutable. I feel a little anxious why I think

error C2039: 'string' : is not a member of 'std', header file problem

杀马特。学长 韩版系。学妹 提交于 2020-03-17 06:41:26
问题 I am having problems with a class I am writing. I have split the class into a .h file that defines the class and an .cpp file that implements the class. I receive this error in Visual Studio 2010 Express: error C2039: 'string' : is not a member of 'std' This is the header FMAT.h class string; class FMAT { public: FMAT(); ~FMAT(); int session(); private: int manualSession(); int autoSession(); int mode; std::string instructionFile; }; This is the implementation file FMAT.cpp #include <iostream

C++ headers redefining/declaring mixup

蹲街弑〆低调 提交于 2020-02-16 06:53:46
问题 I'm trying to abstract out a method from a simple program. This method tests the length of an array against a predeclared CAPACITY constant, and spits out an error message if conditions aren't met. However, I'm having trouble creating a header file with a .cpp file to hold the method. the header file: //arrayHelper.h #ifndef ARRAYHELPER_H #define ARRAYHELPER_H void arrayLengthCheck(int & length, const int capacity, string prompt); #endif // ARRAYHELPER_H the code file: //arrayHelper.cpp

C++ headers redefining/declaring mixup

筅森魡賤 提交于 2020-02-16 06:53:24
问题 I'm trying to abstract out a method from a simple program. This method tests the length of an array against a predeclared CAPACITY constant, and spits out an error message if conditions aren't met. However, I'm having trouble creating a header file with a .cpp file to hold the method. the header file: //arrayHelper.h #ifndef ARRAYHELPER_H #define ARRAYHELPER_H void arrayLengthCheck(int & length, const int capacity, string prompt); #endif // ARRAYHELPER_H the code file: //arrayHelper.cpp

How to quickly identify functions from header files?

情到浓时终转凉″ 提交于 2020-02-07 07:29:54
问题 I'm somewhat new to C/C++, and I find myself spending exorbitant amounts of time searching through header files (one innocent include might actually bring dozens more header files with it). Even helpful IDEs like Visual Studio aren't always helpful; sometimes when I try to go to the definition of a function, it prompts me to choose from several--the very thing I was trying to avoid. So...in a very large project with thousands of header files and many occurrences of functions that share the

Cmake not handling header files build dependencies if build dir is a subdirectory of PROJECT_SOURCE_DIR?

ⅰ亾dé卋堺 提交于 2020-02-06 07:59:11
问题 The accepted answer of this question correctly states that cmake does not handle C++ header-files build dependencies in case cmake's build directory is under cmake's PROJECT_SOURCE_DIR . PROJECT_SOURCE_DIR is assigned its value when the cmake project() macro is used, therefore it would be the "top" directory for such a project structure using project(source) : top | |--CmakeLists.txt |--source |--build As far as I know, this is the typical structure of a cmake project, so I find it surprising

Cmake not handling header files build dependencies if build dir is a subdirectory of PROJECT_SOURCE_DIR?

一曲冷凌霜 提交于 2020-02-06 07:58:41
问题 The accepted answer of this question correctly states that cmake does not handle C++ header-files build dependencies in case cmake's build directory is under cmake's PROJECT_SOURCE_DIR . PROJECT_SOURCE_DIR is assigned its value when the cmake project() macro is used, therefore it would be the "top" directory for such a project structure using project(source) : top | |--CmakeLists.txt |--source |--build As far as I know, this is the typical structure of a cmake project, so I find it surprising