gte Posted November 23, 2009 Share Posted November 23, 2009 I'm learning c++ now, and have had ridiculous time wasting problems, related to includes mostly, with VS2008 for c++. I can now really appreciate the time spent in making the AIT includes pretty much flawless. Just wondering if that's common place, and if anyone has a better IDE/compiler to recommend for me to use? It appears that scite can be used with c++, and I love scite with AIT, does anyone have experience using it with c++? The only api that did not have a broken download link here http://groups.google.com/group/scite-interest/web/extras was the windows api. Thanks for reading, I'd love to hear first hand experiences. HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Valik Posted November 24, 2009 Share Posted November 24, 2009 get, if you're having trouble with an IDE that does a lot of the work for you then you're going to struggle even more mightily with SciTE where you essentially have to do everything yourself. You'd be better served to post whatever problems you are having and let others point you in the right direction. Link to comment Share on other sites More sharing options...
danielkza Posted November 25, 2009 Share Posted November 25, 2009 I tried diff. IDEs (NetBeans, Eclipse and DevC++, precisely), and Visual Studio beat them all. And all of them are orders of magnitude ahead of SciTE, specially if you want assistance (autocompleting, IntelliSense, etc) while you code.One thing I can suggest (if you didn't know it already), is joining StackOverflow. You'll find answers to pretty much every problem you have (specially when you're starting to grasp a language or programming in general). The reputation system works quite well: I have not seen any instance of trolling whatsoever, and the community is very friendly to newcomers. Link to comment Share on other sites More sharing options...
bo8ster Posted November 25, 2009 Share Posted November 25, 2009 Read this Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
gte Posted November 29, 2009 Author Share Posted November 29, 2009 The troubles I have with VS is with includes. Just about every include that I add fails and requires a ton of work to try and get it to compile without include errors. For some reason stdafx wouldn't compile right the other day?With the AIT help file (which I love, thank you!) and Scite, I've never had an include issue, it tells you which include you need, if you need one, and I add it and it compiles. With VS, there is no help file, and I have a choice of starting a dozen or so projects. I try and always pick an empty console application (since I am learning) and I seem to always have include/compile errors. Would you like me to go back through my starter projects and see if I can generate another error and post the specific error?get, if you're having trouble with an IDE that does a lot of the work for you then you're going to struggle even more mightily with SciTE where you essentially have to do everything yourself. You'd be better served to post whatever problems you are having and let others point you in the right direction. HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
monoceres Posted November 29, 2009 Share Posted November 29, 2009 Building stuff in C++ is a way more complex process than in most languages. This is because C++ makes use of separate compilation. Lack of understanding of that process almost always results in failure when trying to make use of anything but standard C++. Describing how it works and why is to much to describe in this one post, so go grab a book or something. However I will say one thing, just because you include something doesn't mean you have access to the library, it means you have the description of the library (open a .h file to see for yourself, it just contains declarations!). However an empty console project is almost to easy in Visual Studio, New->Project->Win32->Win32 Console Application. When the project is created just add a .cpp file to the project and write your code in it, don't forget int main(). Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Valik Posted November 29, 2009 Share Posted November 29, 2009 The troubles I have with VS is with includes. Just about every include that I add fails and requires a ton of work to try and get it to compile without include errors.Then you must have a configuration issue or you don't understand the difference between C++'s #include <> and #include "".For some reason stdafx wouldn't compile right the other day?Magic 8 ball says, "That's not helpful information". Why wouldn't it compile? A pre-compiled header won't compile if you're struggling to use #include right in the first place since... well it's based on optimizing the compile time of static #include statements.With VS, there is no help fileYes it does. Visual Studio 2005, 2008 and 2010 install a light version of MSDN. You can freely download the full version of MSDN from the internets. Search on Microsoft's site for "MSDN Library" and download and install the appropriate version for your version of Visual Studio. Link to comment Share on other sites More sharing options...
gte Posted December 4, 2009 Author Share Posted December 4, 2009 Ok Here is an example of another include error, it's failing at this line #include <iostream>, I believe it's trying to tell me that it doesn't recognize this include? error C2447: '{' : missing function header (old-style formal list?) expandcollapse popup// module4.cpp : main project file. // #include "stdafx.h" using namespace System; // //int main(array<System::String ^> ^args) //{ // Console::WriteLine(L"Hello World"); // return 0; //} /****************************************************/ /* File: name of your file with the source code */ /* */ /* Created by: give your name */ /* Date: give the date */ /* */ /* Program to compute binomial coefficients */ /* */ /* Inputs: (keyboard) */ /* Two positive integers (n & k) */ /* */ /* Output: */ /* Corresponding binomial coefficient (nCk) */ /* */ /* Algorithm: see attached description */ /****************************************************/ #include <iostream> using namespace std ; int binomial(int n, int k) ; // function prototype int main() { int n, k ; // parameters for the binomial number int result ; cout << endl ; // read in n & k cout << "Enter n (positive integer) : " ; cin >> n ; cout << "Enter k (positive integer) : " ; cin >> k ; // result = Write the function call ; cout << "Binomial number " << n << "Choose" << k << " = " << result << endl ; return (0) ; } // ******************************************************** int binomial(int n, int k) ; /* Computes the binomial coefficient nCk */ /* */ /* Inputs: */ /* n, k (integers) */ /* */ /* Output: */ /* binomial coefficient nCk (integer) */ { int numerator, denominator ; int i ; // needed to compute numerator & denominator if ( k < n ) // Write if-test { return( 0 ) ; cout << "Value 'k' cannot be larger than value 'n'" << endl ; // Write return value } else { denominator = k ; // Write initial value for (i = 1; i <= k; i = i+1) denominator = k * (k-i) ; cout << k << endl ; // Write code to compute numerator, along similar lines return ( k ) ; //Write return value } } HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Valik Posted December 4, 2009 Share Posted December 4, 2009 And the contents of Stdafx.h are? Link to comment Share on other sites More sharing options...
gte Posted December 4, 2009 Author Share Posted December 4, 2009 By right clicking on it and choosing view code, this is what came about: // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once // TODO: reference additional headers your program requires here HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 4, 2009 Share Posted December 4, 2009 The problem is this section. int binomial(int n, int k) ; /* Computes the binomial coefficient nCk */ /* */ /* Inputs: */ /* n, k (integers) */ /* */ /* Output: */ /* binomial coefficient nCk (integer) */ { You've got a semicolon after the function name, so the { is wrong. Link to comment Share on other sites More sharing options...
gte Posted December 4, 2009 Author Share Posted December 4, 2009 Thanks Richard! The code from the assignment actually had that in it? So whenever you declare function name, you do not follow it with a semicolon? The problem is this section. int binomial(int n, int k) ; /* Computes the binomial coefficient nCk */ /* */ /* Inputs: */ /* n, k (integers) */ /* */ /* Output: */ /* binomial coefficient nCk (integer) */ { You've got a semicolon after the function name, so the { is wrong. HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 4, 2009 Share Posted December 4, 2009 When you declare a function it must be followed by either a semicolon or a method body. Both are valid but not at the same time. Link to comment Share on other sites More sharing options...
gte Posted December 4, 2009 Author Share Posted December 4, 2009 Geez, I just do not understand this language or its includes? There has to be some large thing that I am missing, that allows for includes to work? There is no way everyone that tries to learn c++ has these problems? Depending on if I try and predefine it 1>module4.obj : error LNK2028: unresolved token (0A0002BC) "int __cdecl factorial(int)" (?factorial@@$$FYAHH@Z) referenced in function "int __cdecl binomial(int,int)" (?binomial@@$$FYAHHH@Z) 1>module4.obj : error LNK2019: unresolved external symbol "int __cdecl factorial(int)" (?factorial@@$$FYAHH@Z) referenced in function "int __cdecl binomial(int,int)" (?binomial@@$$FYAHHH@Z) or not error C3861: 'factorial': identifier not found expandcollapse popup#include "stdafx.h" using namespace System; #include <iostream> using namespace std ; int binomial(int n, int k) ; // function prototype int factorial(int z) ; int main() { int n, k ; // parameters for the binomial number int result ; cout << endl ; // read in n & k cout << "Enter n (positive integer) : " ; cin >> n ; cout << "Enter k (positive integer) : " ; cin >> k ; // result = Write the function call ; cout << "Binomial number " << n << "Choose" << k << " = " << result << endl ; return (0) ; } // ******************************************************** int binomial(int n, int k) /* Computes the binomial coefficient nCk */ /* */ /* Inputs: */ /* n, k (integers) */ /* */ /* Output: */ /* binomial coefficient nCk (integer) */ { int numerator, denominator ; int i ; // needed to compute numerator & denominator if ( k < n ) // Write if-test { return( 0 ) ; cout << "Value 'k' cannot be larger than value 'n'" << endl ; // Write return value } else { denominator = k ; // Write initial value for (i = 1; i <= k; i = i+1) denominator = (k * factorial (k-1)) ; cout << k << endl ; // Write code to compute numerator, along similar lines return ( k ) ; //Write return value } } HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Valik Posted December 4, 2009 Share Posted December 4, 2009 (edited) The function factorial() is declared but never defined. If you declare it but give it no body then the linker will throw an error because it can't find the function body to link to. If you don't declare it then the compiler doesn't know what you're talking about.Are you sure you are ready for this? You seem to be missing some very fundamental basics. Are you reading a book or trying to piece stuff together from tutorials?Edit: Also, why are you using "using namespace System"? It almost seems like you have copied some C# or managed C++ code and are trying to use that but you aren't compiling with CLR on. Edited December 4, 2009 by Valik Link to comment Share on other sites More sharing options...
gte Posted December 4, 2009 Author Share Posted December 4, 2009 I definitely don't feel ready for this, the book they have for my class is written in psuedocode, and poorly written at that, but I'm not one to give up easily and I'm hoping through determination and the help of more experienced people such as yourself, I'll be able to pick this up. I know that my problems with the compiler are problems with me, and not problems of the compiler, which is good in a way, because I have control over the problems with me. I thought that factorial was a built in function (like "return") and not a function that I had to write, but if I am understanding you correctly, it sounds as if it is not. My assignment gave me the following, and this is the unaltered starting code that they want you to modify. Let me know what you think about it. I did add a few things that I found in researching on the web (because the text book is written in psuedocode so I can't use that) and maybe that's where my problem is? expandcollapse popup/****************************************************/ /* File: name of your file with the source code */ /* */ /* Created by: give your name */ /* Date: give the date */ /* */ /* Program to compute binomial coefficients */ /* */ /* Inputs: (keyboard) */ /* Two positive integers (n & k) */ /* */ /* Output: */ /* Corresponding binomial coefficient (nCk) */ /* */ /* Algorithm: see attached description */ /****************************************************/ #include <iostream> using namespace std ; int binomial(int n, int k) ; // function prototype int main() { int n, k ; // parameters for the binomial number int result ; cout << endl ; // read in n & k cout << "Enter n (positive integer) : " ; cin >> n ; cout << "Enter k (positive integer) : " ; cin >> k ; result = Write the function call ; cout << "Binomial number " << n << "C" << k << " = " << result << endl ; return (0) ; } // ******************************************************** int binomial(int n, int k) /* Computes the binomial coefficient nCk */ /* */ /* Inputs: */ /* n, k (integers) */ /* */ /* Output: */ /* binomial coefficient nCk (integer) */ { int numerator, denominator ; int i ; // needed to compute numerator & denominator if ( ) Write if-test { return( ) ; Write return value } else { denominator = ; Write initial value for (i = ; i <= ; i = i+1) denominator = * ; Write code to compute numerator, along similar lines return ( ) ; Write return value } } The function factorial() is declared but never defined. If you declare it but give it no body then the linker will throw an error because it can't find the function body to link to. If you don't declare it then the compiler doesn't know what you're talking about. Are you sure you are ready for this? You seem to be missing some very fundamental basics. Are you reading a book or trying to piece stuff together from tutorials? Edit: Also, why are you using "using namespace System"? It almost seems like you have copied some C# or managed C++ code and are trying to use that but you aren't compiling with CLR on. HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
bo8ster Posted December 4, 2009 Share Posted December 4, 2009 (edited) Geez, I just do not understand this language or its includes? There has to be some large thing that I am missing, that allows for includes to work? There is no way everyone that tries to learn c++ has these problems? Apart from what Valik said it is clear you have not learnt from a book. The ordering includes, comments and general layout is not common to an example you would find. Example: I would expect see includes to be listed like: using namespace System; using namespace std ; #include <iostream> #include "stdafx.h" Understanding what each line does goes a long way to understanding why I would list them in that order. There is a thread here and here that have some good links. Understand the basics first then you will understand the compiler more - as my lecture always said "the compiler is always right" - it was annoying but you learn Edit: Just saw your last post - the factorial function is not built in, in fact there is only a handful of key works in C++, the rest is made up by libraries. Help files give you the contents of the libraries and over time you remember them. Example: cout is not apart of C++ like return is, it is apart of the iostream library which you included at the top of the file. Edited December 4, 2009 by bo8ster Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
turbov21 Posted December 4, 2009 Share Posted December 4, 2009 (edited) I don't do much C++, and when I do it's usually on a Linux system, so I have to say g++. Not a very educated recommendation, I'm afraid, but it and gcc have never let me down. Edited December 4, 2009 by turbov21 Link to comment Share on other sites More sharing options...
bo8ster Posted December 4, 2009 Share Posted December 4, 2009 I don't do much C++, and when I do it's usually on a Linux system, so I have to say g++. Not a very educated recommendation, I'm afraid, but it and gcc have never let me down.I understand gcc and g++ are the same, thus g++ uses gcc. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
gte Posted December 4, 2009 Author Share Posted December 4, 2009 Looking in the help file for "factorial c++" lends results to the below, and what's confusing about this, is that there is no includes, and it appears that it's calling the function factorial inside of itself, without ever really defining it? int factorial( int num ); /* Function prototype */ void main() { int result, number; . . . result = factorial( number ); } int factorial( int num ) /* Function definition */ { . . . if ( ( num > 0 ) || ( num <= 10 ) ) return( num * factorial( num - 1 ) ); } Apart from what Valik said it is clear you have not learnt from a book. The ordering includes, comments and general layout is not common to an example you would find. Example: I would expect see includes to be listed like: using namespace System; using namespace std ; #include <iostream> #include "stdafx.h" Understanding what each line does goes a long way to understanding why I would list them in that order. There is a thread here and here that have some good links. Understand the basics first then you will understand the compiler more - as my lecture always said "the compiler is always right" - it was annoying but you learn Edit: Just saw your last post - the factorial function is not built in, in fact there is only a handful of key works in C++, the rest is made up by libraries. Help files give you the contents of the libraries and over time you remember them. Example: cout is not apart of C++ like return is, it is apart of the iostream library which you included at the top of the file. HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now