Qbasicnews.com
i hate devc++ - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: General (http://qbasicnews.com/newforum/forum-6.html)
+--- Forum: General/Misc (http://qbasicnews.com/newforum/forum-18.html)
+---- Forum: General Programming (http://qbasicnews.com/newforum/forum-20.html)
+---- Thread: i hate devc++ (/thread-8245.html)

Pages: 1 2


i hate devc++ - xteraco - 10-15-2005

i'm trying to figure out why this wont work in devc++

Code:
#include <iostream>
using namespace std;

void func1();
void func2();

int count; // this is a global variable

int main()
{
    int i; // this is a local variable
    
    for(i=0; i<10; i++) {
             count = i * 2;
             func1();
             }
            
             return 0;
             }
            
             void func1()
             {
                  cout << "count: " << count; // access global variable
                  cout << "\n"; // output a newline
                  func2();
                  }
                  
                  void func2()

devc++ is really about to piss me off.. i cant get it to compile crap, it couldnt compile "hello world" on i good day, i swear... does anybody know of a better "free" compiler?

PLEASE HELP!!


i hate devc++ - xteraco - 10-15-2005

i havent really used devc++ that much, just because everytime i use it, i come across some type of problem

this compiles fine
Code:
#include <iostream>
using namespace std;

int global_var;

int main()
{
    int holder;
    global_var = 100;
    cout << global_var;
    cin >> holder;
    return 0;
}

wich means the problem isnt global variables, wich is a good thing


i hate devc++ - Jofers - 10-15-2005

First off, DevC++ is an IDE, not a compiler. It provides an environment for gcc, which is the standard "free" compiler. C++ itself is a standardized language, it is the same across all compilers.

This works fine for me. Prefix the global variables with "::":
Code:
#include <iostream>
using namespace std;

void func1();
void func2();

int count; // this is a global variable

int main()
    {
        int i; // this is a local variable
      
        for(i=0; i<10; i++) {
            ::count = i * 2;
            func1();
        }
        system("PAUSE");
        return 0;
    }
            
void func1()
   {
       cout << "count: " << ::count; // access global variable
       cout << "\n"; // output a newline
       func2();
   }

                
void func2() {}
It was probably in a namespace conflict with std::count or something.


i hate devc++ - rpgfan3233 - 10-15-2005

Quote:It was probably in a namespace conflict with std::count or something.
That's right, Jofers: http://support.roguewave.com/support/docs/leif/sourcepro/html/stdlibref/count.html

Changing your variable name would be just as good. :-)
Maybe "myCount" or something?


Re: i hate devc++ - Dr_Davenstein - 10-15-2005

Quote:i hate devc++

Me too! :evil:


i hate devc++ - mjs - 10-15-2005

I don't use DevC++ too. Instead, I stick with GNU make. It's simple and it works. 8)

Regards,
Mark


i hate devc++ - Deleter - 10-15-2005

Quote:I don't use DevC++ too. Instead, I stick with GNU make. It's simple and it works. 8)

Regards,
Mark
i stick with freebasic, because its simpler and works. Tongue


i hate devc++ - Oz - 10-15-2005

i have devc++, but since i'm not a hard-core c++ programmer, i don't complain when i use it.....it's only for testing code..that's about it.

you may find it better practice (not really, but hey) to create your own namespace, thus you won't get any conflicts with your variables, but you constantly have to have YourNameSpace::Yourvar

oz~


i hate devc++ - MystikShadows - 10-15-2005

One compiler I like (it's a compiler/ide/everything thing lol) is Pelles C
http://www.smorgasbordet.com/pellesc/

this is C, not C++ ;-)


i hate devc++ - rpgfan3233 - 10-16-2005

By the way, did you download all of the Dev-C++ updates? That may be something you'll want to consider. . .