athlon32 56 Junior Poster in Training

well, it sounds like what you really should be using is a dynamic container like a vector, or a list...arrays are good, but they tend to waste precious memory :)

I can understand if you're a noob, but vectors aren't hard at all:
http://cplusplus.com/reference/stl/vector/

Hope I helped :)

athlon32 56 Junior Poster in Training
athlon32 56 Junior Poster in Training

Are you root or using sudo?

athlon32 56 Junior Poster in Training

All the tobasco sauce I just drank. I can't fell my tongue.
Does that answer your question?

ROFL

athlon32 56 Junior Poster in Training

Welcome to Win32 :) As long as your compiler/IDE supports Win32, and has all the includes (windows.h, etc.) It'll work. In my opinion the best compiler is Code::Blocks (http://www.codeblocks.org/)

if I can just start coding right away or do I need to download libraries etc

probably not :)

Hope I helped :)

athlon32 56 Junior Poster in Training
athlon32 56 Junior Poster in Training

Is this your first time with GUIs??? If so, i suggest learning Gtk+ first, it makes understanding Win32 much easier

Technically, you could make a window with just this:

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int CmdShow)
{

    MessageBox(NULL, TEXT("First Program"), TEXT("First"), MB_OK );

    return 0;
}

But normally a Win32 window looks like this:

#include <windows.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
  MSG  msg ;    
  HWND hwnd;
  WNDCLASS wc;
	
  wc.style         = CS_HREDRAW | CS_VREDRAW;
  wc.cbClsExtra    = 0;
  wc.cbWndExtra    = 0;
  wc.lpszClassName = TEXT( "Window" );
  wc.hInstance     = hInstance ;
  wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  wc.lpszMenuName  = NULL;
  wc.lpfnWndProc   = WndProc;
  wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
  
  RegisterClass(&wc);
  hwnd = CreateWindow( wc.lpszClassName, TEXT("Window"),
                WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                100, 100, 250, 150, NULL, NULL, hInstance, NULL);  

  ShowWindow(hwnd, nCmdShow);
  UpdateWindow(hwnd);

  while( GetMessage(&msg, NULL, 0, 0)) {
    DispatchMessage(&msg);
  }
  return (int) msg.wParam;
}

LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
  switch(msg)  
  {
    case WM_DESTROY:
      {
        PostQuitMessage(0);
        return 0;
      }
  }
  return DefWindowProc(hwnd, msg, wParam, lParam);
}

seems like a lot of crap for just a simple window, right? Well everything in that example has a purpose.

This explains it very well:
http://zetcode.com/tutorials/winapi/window/

As for a good tutorial look at this one:
http://zetcode.com/tutorials/winapi/

athlon32 56 Junior Poster in Training

Thanks i will try that,so now here is what i think about application programming : You dont need to know for example a lot of c++(except functions,classes)

that's not necessarily true, you should probably know pointers and references if you want to product code that is worthwhile

,the main thing about making applications is the GUI,i sow examples of Qt4 and all the stuffs were made in Qt4,there was nothing like "cout" and etc,or i am wrong about the meaning for making applications ?

Many times toolkits take things like consle output into there own hands. For example in Gtk+ there is not printf() ; instead you use g_print() . This stuff depends on the toolkit/API

I also noticed you've gotten referals to like 5 different toolkits/APIs; I just wanted to say this:

I suggest learning Gtk+ as your first GUI toolkit, here's an article about it, and why it's good etc:
http://www.freesoftwaremagazine.com/community_posts/why_gtk_may_just_be_best_gui_toolkit_ever

Once you have some experience in GUIs move onto Win32 if you are planning to do anything in Windows. Win32 is the best way to make GUIs in Windows

Hope I helped :)

athlon32 56 Junior Poster in Training

Welcome to Linux!

First of all not all programs for Linux are open source!!! Infact, in some cases it is illegal to look at certain programs source code!!! (just thought I'd mention that)

>I haven't really seen anything
Your probably not looking right...for example...in Ubuntu you can view the Linux Kernel source code by going to the directory: /usr/src/ cd /usr/src generally when you install a program, you don't really work with the source code(you work with binaries), unless you compile it, almost always the project supplies the source code in a separate tarball for downloading, you just gotta find them.

A good example of this is the mozilla FTP server:
the binaries are located here:
ftp://ftp.mozilla.org/pub/firefox/releases/3.5rc3/linux-i686/

and the source is here:
ftp://ftp.mozilla.org/pub/firefox/releases/3.5rc3/source/

get it?

Sometimes however, programs installed also will bring the source, this is generally stored in a directory called "src"

for example there might be a pidgin/src/ or mozilla/src/ directory on your system. Those would hold source code

Just for your reference
/bin - binaries
/lib - libraries
/src - source

> When applied to a folder, the execute permission has nothing to do with
running programs. Instead, the execute permission controls who can
access or modify the small folder file.

That just means if you have a program located in a file, and you aren't allowed to access that folder, you can't run that …

valinux commented: Thanks a lot. That explained it really well. I read that bit about the binaries and compiling it, but it didn't make sense before. Thanks again. +1
athlon32 56 Junior Poster in Training

Hi again,first i must say that i am familiar with c++ but only console programming. I am beginner so can you please be more gentle. I want to move on programming with buttons,windows,check boxs,input box and so on,i have heard of API and GUI what is the diference ? They are used for ? And when i try to compile some code Qt 4 code with DevC++ it gives me a lot of error,can you tell me why i get that error,do i need new compiler or there are missing compiler libraries ? Thanks for your help and lost time with my problem :)

Basically an API is like a library, or a bunch of resources that one progammer/programmers made for others to implement.

A GUI is any program that interacts with the user with graphics

The reason Qt isn't compiling is probably because you're doing it wrong, or you don't have qt on your computer. What OS are you using? It should come with most KDE linux distros

I suggest learning Gtk+, it's much easier for beginners
http://zetcode.com/tutorials/gtktutorial/

Hope I helped :)

athlon32 56 Junior Poster in Training

2. Why address of a and b are same.

They are not, i ran it on my computer and i get 2 different addresses

3. If I use copy constructor here, then the first line of main() is giving error

Look at my answer to #5

4. Constructor is getting called for object b which it should be, but destructor is getting called for object a.

I don't think so, I removed the function fun() and left only a, and it gave me both destructor/constructor messages...i think the des/con aren't being called on B :?

5)Why am i not allowed to create a copy-constructor in this class?

Because it should be like this:

class A{
      int i;
      public:
            A(){
                   cout<<"default constructor\n";
            }
            ~A(){
                   cout<<"default destrutor\n";
             }


            A(A& obj);
};

and this:

A::A(A& obj)
{
                  i=obj.i;
                  cout<<"copy constructor\n";
};

Here, your code should be:

#include <iostream>

using namespace std;

class A{
      int i;
      public:
            A(){
                   cout<<"default constructor\n";
            }
            ~A(){
                   cout<<"default destrutor\n";
             }

};


A fun(){
      A b;
      cout<<" address of b = "<<&b<<endl;
      return b;
}

int main(){
      A a;
      fun();
      cout<<" address of a = " << &a<<endl;
      return 0;
}
csurfer commented: Lots of wrong info there buddy...check once before posting. +0
athlon32 56 Junior Poster in Training

I googled it, and i think this was the only relevant link
http://www.codeguru.com/cpp/w-p/ce/networking/article.php/c7431

Hope I helped :)

athlon32 56 Junior Poster in Training

You could probably do that in Java or Javascript, those two are very similar to C++, in fact Java practically is C++

I would suggest Java over javascript because it's a real application language, it's totally OOP (so is Javascript, but in a different way)

I'm guessing you know java, but if you don't look for a few good tutorials about it on google:
http://www.google.com/#hl=en&q=java+tutorial&aq=f&oq=&aqi=g10&fp=OzgK0dwM7rU

Like i said, java and javascript are very similar; Java has most of the features of C++, and their syntax is so alike :)

hope i helped :)

athlon32 56 Junior Poster in Training

Sorry, I don't use VC++, i prefer Code::Blocks; but I'm guessing that Form1.h has a bunch of extra declarations that are defined in separate .CPP files that you mustn't get to see, maybe, or maybe not

athlon32 56 Junior Poster in Training

The .h file traditionally holds declarations and the .cpp file the definitions. The #include inserts the human readable ASCII code that is the .h file, right there at the top before compiling. The main purpose of the .h file was to gather together all the declarations (more even than you need) rather than listing all that are needed at the top of every .cpp file. (This also eliminates the need to go around changing every declaration every time you make a change.)

That Much is true :)

But in the case of Windows Programming (using Visual C++ Express) why is all the code in the form1.h and the .cpp file that includes it is just a stub?

I don't understand, why don't you post Form1.h???

athlon32 56 Junior Poster in Training

Your code should be:

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance,
				   HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine,
				   int nShowCmd)
{
    MessageBox(NULL, "Hello World!",
               "TEST",
               MB_ICONEXCLAMATION | MB_OK);
	return 0;
}

Your problem was on lines 8, and 9 :)

athlon32 56 Junior Poster in Training
athlon32 56 Junior Poster in Training

I have a class (String) that I want to be able to implicitly convert to a char. How would I go about doing this? I know to do it the other way around, I just add a constructor that just takes a char as a parameter, but to convert from String to char implicitly? Thanks.

This any help???:
http://support.microsoft.com/?kbid=311259

athlon32 56 Junior Poster in Training

My friend and I are trying to write a program for my Spanish teacher so that she can just type Spanish words and English words into an application, those words get stored as an array somewhere, and then another program that tests the kids uses that array. The program gives them the Spanish, then they give it the English. Could anybody help us with this because we don't even know where to start even though we both know a substantial amount of C and C++ programming.

well...this really looks like an OOP type of problem.

try making a language class that has an array...and use inheritance for spanish and english, then make objects for each word, and in the constructor maybe you could enter the word as a parmeter and store it to the array, then just call all that stuff as needed.

get what I'm saying??? just think about the prob for a while, it'll come to you soon :D