Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed yesterday.
Improve this question
I have header (*.hxx) and implementation (*.cxx) files.
Additionally, I don't want to put all my code into the header file.
I would like to keep the header file as small as it's possible.
In this case: how to declare inline method in my class?
question.hxx
class question
{
int get_value();
};
question.cxx
int question::get_value()
{
return 0;
}
A tiny sample code in C++.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
To clarify I was wondering how to return the type of a class within the class definition.
Even though an answer was given I ended up reverting back to using a virtual function, which kind of made more sense in the long run.
Sorry for the confusion.
You could write A as the return type? Classes define user-defined types, meaning they can be used as return types. Sorry, if I misinterpreted your question though, and if there is an error, please point it out. Anyways, here is the code below:
class A
{
//....
public:
A someFunction();
//.....
}
//implementation:
A A::someFunction()
{
//Code....
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a matrix in one class. That matrix is allocated dinamically, I want to encapsulate it.
Here is my matrix declaration in the Header file:
float** matrix;
And here is the declaration of get method:
float *getMatrix();
Is everything correct so far?
I don't know how to work with pointers in that case. How would the get function look like?
if you want just to return matrix you should use
float** getMatrix();
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I was looking at some code and it had the following line:
#include "point.h" // Added by ClassView
I understand that "point.h" is a class with members, functions? If yes, how can I view it?
point.h is a file, nothing more and nothing less.
To see the contents of the file, simply open the file.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Currently, I have code like:
static YAML::Node *doc;
...
__attribute__((constructor)) void inityaml() {
doc = new YAML::Node;
parser.GetNextDocument(*doc);
}
The question is, is there any more C++-conventions-ish way to perform this task, like the use of a global reference or something?
Why not avoid heap allocation altogether?
i.e.
static YAML::Node doc;
...
void inityaml() {
parser.GetNextDocument(&doc);
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Any ideas why I keep getting this error?
http://codepad.org/jPQzMWvG
You declared a destructor in the header (line 36), but you haven't defined it in the source code. Add this to the source code, and you should be fine :
Entity::~Entity()
{
// do the cleanup here
}
Your class definition includes a destructor ~Entity but there's no implementation for it in the Entity.cpp file.
You've declared a destructor ~Entity() (and also ~Block()), but not implemented them anywhere. If the destructors are necessary, then implement them; otherwise, remove the declarations.
By the way, you should post the code in the question rather than an external website.