Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: c++ code errors, need help...

Started 1 month, 1 week ago by jzimmerman2011
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()...
Site: CodeGuru Forums - A Developer.com Community for C++, C#, VB, Java and .NET Solutions  CodeGuru Forums - A Developer.com Community for C++, C#, VB, Java and .NET Solutions - site profile
Forum: C++ (Non Visual C++ Issues)  C++ (Non Visual C++ Issues) - forum profile
Total authors: 341 author
Total thread posts: 5 posts
Thread activity: 514 new posts during last week
Domain info for: codeguru.com

Other posts in this thread:

Zachm's Avatar replied 3 months, 1 week ago
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; ...

monarch_dodra replied 3 months, 1 week ago
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?

monarch_dodra Member replied 3 months, 1 week ago
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) { }

Zachm's Avatar replied 3 months, 1 week ago
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:...

divined divined is offline Member replied 3 months, 1 week ago
ok. thx. I understand that this has to with protecting the structure - class instance from accidental modification.

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...

JohnW@Wessex replied 3 months, 1 week ago
Quote: Originally Posted by Muthuveerappan I think it works on msvc It does. Code: *p1 = 5 p1 = 0012FF60 &p1 = 0012FF48 *p2 = 5 p2 = 0012FF60 &p2 = 0012FF48 *p1 = 6 p1 = 0012FF54 &p1 = 0012FF48 *p2 = 6 p2 = 0012FF54 &p2 = 0012FF48

aryan1 Member replied 3 months, 1 week ago
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 ...

 

Top contributing authors

Name
Posts
Paul McKenzie
147
user's latest post:
Good practice for knowing if...
Published (2009-12-14 13:44:00)
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....
laserlight
126
user's latest post:
Why Use Pointers
Published (2009-12-14 12:08:00)
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...
Lindley
122
user's latest post:
Good practice for knowing if...
Published (2009-12-14 12:48:00)
FYI, if you have a vector&lt;int&gt; and an interface like Code: void dosomething(int *array, size_t length); you can always call it like Code: vector&lt;int&gt; myvec(20); dosomething(&amp;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.
treuss
90
user's latest post:
Why Use Pointers
Published (2009-12-14 04:16:00)
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...
ninja9578
75
user's latest post:
Good practice for knowing if...
Published (2009-12-14 12:37:00)
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.
GCDEF
70
user's latest post:
Question
Published (2009-12-11 21:01:00)
wat
dukevn
64
user's latest post:
best way to deal with big array...
Published (2009-12-13 12:46:00)
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.
monarch_dodra
55
user's latest post:
ifstream
Published (2009-12-04 04:10:00)
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 &lt;&lt; &quot;isBad&quot; &lt;&lt; mapIn &lt;&lt; endl You have two...
D_Drmmr
43
user's latest post:
c++ gurus i beg you help me...
Published (2009-12-13 04:52:00)
http://www.codeguru.com/forum/showthread.php?t=366302
couling
41
user's latest post:
Using exceptions in the real world.
Published (2009-11-28 13:01:00)
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":

Related threads on other sites:

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