This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
if((kulax>=schodki[i][0][0] && kulax<=schodki[i][1]][0]) && (kulay==schodki[i][2][0]+10))
spoczywa=true;
Hi guys, I have an array of integers which name is schodki and it is declared as int schodki[5][3][1] and the global variables : int kulax and int kulay.
What's wrong in the line of code which is above ?
EDIT : Of course. "i" is the value from current state of loop.
You have an extra ] in
kulax<=schodki[i][1]][0]
which probably screws up parsing and results in a confusing error message. The compiler probably sees it as
kulax<=schodki[i][1]
which is indeed an attempt to compare an integer to a pointer. Try to pay attention to your own code and make sure it is free from primitive syntax errors before asking questions here.
Other than that, there's nothing wrong with your code (assuming that the variables are really declared the way you say they are)].
Related
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I found a C++ file in PARSEC benchmark suite and saw some functions like this:
long Rng::rand()
{
return _rng->randInt();
}
what does the :: in the name of the function do here?
In C, :: is a syntax error unless it occurs inside a comment, a character literal or a string literal.
The :: can only appear in C++ code.
In C++ :: is the Scope resolution operator.
In this case it tells the compiler that it is a defintiion for rand() method which is a member function for Rng class/structure/union/namespace.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I have the following class:
class clsTree;
{
private:
vector<clsNode*>m_content;
m_RootNode *clsNode;
m_LastNode *clsNode;
public:
vector<clsNode*>Content;
wstring interpret(wstring uWord);
};
The compiler does not like my member declaration of clsNode at all.
The first error I get is "Member clsTree::clsNode is not a type name.".
I don't see where I went wrong.
Can somebody help, please?
You're not showing the definition of clsNode, neither whether you have a forward declaration for it, but I'm pretty sure this:
m_RootNode *clsNode;
m_LastNode *clsNode;
Should be rewritten this way:
clsNode* m_RootNode;
clsNode* m_LastNode;
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
Do I need to provide == and/or != operators? I've read here: Why don't C++ compilers define operator== and operator!=? that I do but when I actually tried it (didn't provide them and tried to use them) the program compiled fine. So what's going on?
Using VS2010 if it matters.
These operators are defined for fundamental, language-defined types, not for your custom ones. So it will work for ints, for example. But won't for class foo; unless you provide them explicitly - compiler doesn't know how to compare your own defined types if you haven't told it how to do it.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I've seen a pretty strange (for me) usage of this method:
strncpy(somePointer,"%d",someInt);
What does this actually do? The integer specifier "%d" as the source is troublesome for me to understand.
It does what it says on the tin: It copies the literal string "%d" into a char buffer pointed to by somePointer, or at least the first someInt bytes of it (up to three).
Don't be upset by a percentage sign, it's just another character...
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I am reading book "Thinking in C++" Bruce Eckel. The Chapter 3 in page 164(Polish edition)is about pointer to function.
Examples from the book:
void * (*(*fp1)(int))[10]
float (*(*fp2)(int,int,float))(int)
double (*(*(*fp3)())[10])()
int (*(*f4())[10])()
Can you tell me how I should interpret this and what is created by these examples because I do not understand the book solution?
I hope this tricky rule will help you to unwind such conundrums:
http://c-faq.com/decl/spiral.anderson.html
Let's take 4: int (*(*f4())[10])()
It reads f4 evaluated (f4()) and then dereferenced ((*f4())) can be subscribed ((*f4())[10]) then dereferenced ((*(*f4())[10])) and evaluated to give an int (int (*(*f4())[10])()).
It is thus a function returning a pointer of arrays to pointers of functions returning int.