i am new to c++ (and i hate it, i might add), and i am working on a project for my cs class. i have been trying for hours to get this code to compile, and i can't get it to work:
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
class TrieNode
{
private:
char data;
bool isWord;
TrieNode childNodes;
public:
TrieNode()...
I think you are making sense, but not to anyone which is a C++ programmer .
Maybe an example will help you understand:
Code:
#include <iostream>
int main()
{
//define an integer variable named 'celsius' and assign the value -140000 to it.
int celsius = -140000;
//print the value of the variable named 'celsius'
std::cout << celsius << endl;
...
Quote:
Originally Posted by endless_dark
It's me again : /
/****************************************
row[0] (1,2,3,4,1,2);
row[1]= row(1,2,3,4,1,2);
row[2]= row(1,2,3,4,1,2);
row[3]= row(1,2,3,4,1,2);
row[4]= row(1,2,3,4,1,2);
****************************************/ <--- This part of the code is ...
GNiewerth Senior Member replied 3 months, 1 week ago
I´ve got two different compilers here, the help of one says tolower/isalpha reside in <ctype.h>, the other one says they reside in <locale>
Maybe <string> includes them already, so you don´t have to include it explicitely.
I´ve got no clue what the const reference error might be, perhaps you can post a code sample?
Quote:
Originally Posted by Suamere
It all works fine, but I'm wondering if ctype.h SHOULD be there for some reason, and if the pointer reference should be there in the arguments, and if so, why and how I make it work properly.
You have to understand the point of using a reference...
If you pass a reference, then ...
divined divined is offline Member replied 3 months, 1 week ago
Hello everybody
I`m been reading some c++ programming books lately and I`ve run across functions declarations like the one shown below :
Code:
CQ::CQ(const st &st)
{
}
My question is now, why would one one to declare the parameter as a constant? Would it not be the same to declare it as
CQ::CQ(st &st)
{
}
First of all, I think you got it a little wrong, you can't have a function/method/constructor declaration/definition that looks like that:
Code:
CQ::CQ(const st &st)
{
}
'st' is a type, struct or class and therefore can't serve also as the parameter name. Assuming the class/type/struct is named 'St' (case matters), it probably should have looked something like this:
Code:...
GNiewerth GNiewerth is offline Senior Member replied 3 months, 1 week ago
const references are allowed to reference temporary objects, whereas references aren´t. This allows implicit type conversion, i.e.:
Code:
#include <string>
void f1( std::string& s )
{
}
void f2( const std::string& s )
{
}
int main()
{
f1( "Hello" ); // invalid, results in a reference to a temporary
f2( "World" ); // valid, results in a const reference to...
Hi All,
Is there any C/C++ API in Linux that I can use to get the names of the files in a folder with a certain extension ?
I came across readdir() and scandir() functions.
readdir() gives the list of all files - it does not seem to be providing any filtering option.
scandir() provides some filtering options, but I could not understand if it is capable of giving me the names ...
Quote: Originally Posted by ninja9578 I also create libraries in C++ for languages other than C++, so to interface with them, I have to use arrays too. I create DLL's, and within the DLL code itself, you can use anything you want in C++. As Arjay stated, as long as the interface to the function uses arrays, that's all that is needed. Inside the function, you have free reign to do anything you want, use any container you want, etc....
Quote: Originally Posted by ninja9578 Java is ambiguous, maybe not in definition, but when looking at it. Nah, you are just making mistake similiar to what many Java programmers make when they learn C++: you look at the syntax from a C++ point of view, then conclude that it is flawed in Java because you have forgotten what it means in Java. But a Java programmer could take one look at the code and see no ambiguity because the meaning is...
FYI, if you have a vector<int> and an interface like Code: void dosomething(int *array, size_t length); you can always call it like Code: vector<int> myvec(20); dosomething(&myvec[0], myvec.size()); The only special case you need to be aware of is that when the vector is empty, attempting to access myvec[0] may throw an exception under some implementations.
Quote: Originally Posted by icu222much Sorry about that. And thanks for the speedy reply. Why does C++ even have pointers? Why can't it be like Java where you don't have to say if that is a pointer or not? C++ is simply more flexible. In Java you can only create an object with new and will not know when it gets deleted (garbage collection). In C++ you have three choices: You create an object on the stack and it will automatically...
I use stl containers as much as I can , but sometimes I have no choice other than to use an array. I use a lot of old C libraries, which can't accept stl containers as parameters. I also create libraries in C++ for languages other than C++, so to interface with them, I have to use arrays too.
Quote: Originally Posted by Lindley I can't be sure, but I wouldn't expect it to help very much. Why don't you try and find out? I will, since it is in my learning plan, but not just now because I have a feeling that it will involve more reading and time.
I found your problem, and got your program running. The problem is bad design from a stream handling point of view. If I check your program, you tried to open mapIn: - In your constructor - In checkFile - In loadNext Opening your mapIn more than once without closing it will immediately put it into a bad state. (check mapIn.bad(), or just cout << "isBad" << mapIn << endl You have two...
I've used the first method a fair bit while working with delphi classes as these can't be created on the stack. It never seemd the most elagent solution though. I only mentioned the second method because that was what was shown on cplusplus.com . I've never seen it used in practice. As for the third method. Quote: Originally Posted by D_Drmmr What's undefined about that? It seemed that way because I'm unshore of how...
Related threads on "CodeGuru Forums - A Developer.com Community for C++, C#, VB, Java and .NET Solutions":
Thread profile page for "c++ code errors, need help..." on http://www.codeguru.com.
This report page is a snippet summary view from a single thread "c++ code errors, need help...", located on the Message Board at http://www.codeguru.com.
This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity