flat assembler
Message board for the users of flat assembler.

Index > Heap > Learn C++?

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
I've been thinking about learning C++, but I don't know where to start. I have VC++ 2008 express compiler, when I try to make anything I get "cannot convert between blah and bleh" errors and other frustrations. Does anyone know of any sites that could help me learn C++?
C++ is just so confusing.....If you were to take some C++ coder he would probably say the same thing about assembly lol.

Example of frustration:
Code:
include <windows.h>
 
int WINAPI
    WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, "Hello World! This is my first win32 program!",
        "Lesson1", MB_OK);
 
    return 0;
}
    

It throws some error about messagebox and gives convert errors, so I have to change the source to MessageBoxA.

_________________
----> * <---- My star, won HERE
Post 06 Nov 2008, 02:17
View user's profile Send private message Reply with quote
drhowarddrfine



Joined: 10 Jul 2007
Posts: 535
drhowarddrfine
It can mess with your head.
C++ Programming Tutorials
Post 06 Nov 2008, 02:45
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
windwakr: do you want to learn C, or C++? Example you posted is pure C.

Quote:
It throws some error about messagebox and gives convert errors, so I have to change the source to MessageBoxA.

Well, what errors? Usually, at least the first error is real.
Post 06 Nov 2008, 10:53
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8885
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
thats why i like assembly language.
without type, typeless...
everything is DWORD Smile
Post 06 Nov 2008, 11:21
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1605
Location: Ukraine
shoorick
Quote:

typeless...

sometimes it's good, sometimes you may occasionally add kittens to tomatos and then subtract birthday from result and then guess what you finally got Razz
Post 06 Nov 2008, 12:22
View user's profile Send private message Visit poster's website Reply with quote
drhowarddrfine



Joined: 10 Jul 2007
Posts: 535
drhowarddrfine
PARTY!!!!!
Post 06 Nov 2008, 13:47
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
C++ suxxor. Learn C, I recommend it.

Don't start with OOP, you can do the "virtual functions" in C with function pointers too and it's much more easier to KNOW what it's happening, exactly, not confusing with abstract inheritance Razz

_________________
Previously known as The_Grey_Beast
Post 06 Nov 2008, 14:32
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Thanks for the link drhowarddrfine. It has some good tutorials

Borsuc: ya, I think I'll start with C.
Post 06 Nov 2008, 21:40
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin
learn c++ 1st..
I know both and now learning asm..

almost all programs you find on the net these days use c++ (there is still C out there).. and in windows programs C++ -object oriented programming (OOP) is a must to learn...

also going from c++ to c is easy..

later I will post some good links to get you started and if you can get this book: C++ Black Book...
has very good exapmles of every c++ funtion and how to use them ..
starts off simple up to handleing files...ect.. cover (oop ) style programming
and covers classes.. ect..

Also start with console programs not windows api.. after you understand c++ move to MFC at first then to the win api.. You will pick it up faster this way
Console program:
Code:
#include <iostream>
using namespace std;

int main()
{
  
 
 cout <<"Start with c++\n"<<endl;
 
 return 0;

}

    


if C++ seams to hard start with Java it will teach you the OOP style of programming also.. its easier to learn!

for MFC go here:
http://www.functionx.com/visualc/
Post 06 Nov 2008, 22:25
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Programming the win32 API using C++ is a bit painful, since the PlatformSDK was written with C and not C++ in mind - thus you need a lot of typecasts all over. Indeed, if you want to learn C++, start by learning the language, and do console mode applications. It's not as sexy as GUIs, but at least you'll be focusing on the language. You can always pick up WTL later for GUI stuff.

The problem you're having with MsgBox is probably that you're compiling your application for UNICODE. Don't call MessageBoxA - either set your program to compile for ANSI, or write proper UNICODE capable code: #include <tchar.h>, wrap text literals like _T("blala"), and never use sizeof for text buffers (use a lengthof macro). That way, you can compile for both ANSI and UNICODE.

C++ is good if you do it right. Takes a lot of time to learn properly, though, and you need real books (or ebooks...), not just sucky online "tutorials".
Post 07 Nov 2008, 09:22
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
shoorick,

It's important to add kitten to tomatoes right in that sequence. And remember: stir, do not shake! Or else the mix will go boom and you'll end up with that sticky goo all over the place. Wink

Assembly language is not for faint-hearted, you're telling the hardware what to do exactly. CPU can fail to achieve the goal if you give it even the slightest chance.

windwakr,

It would be right and fitting that you get a copy of ISO/IEC 9899:TC2 international standard. While it's not a fancy reading, definitions there are crucial to deep understanding of C.
Post 07 Nov 2008, 10:28
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1605
Location: Ukraine
shoorick
Quote:
Assembly language is not for faint-hearted,

in assembly you add bytes, words and dwords with same instruction: "add" - it's so easy and obvious! desperate heart has to program with forth! it's worth to try Wink
Post 07 Nov 2008, 12:32
View user's profile Send private message Visit poster's website Reply with quote
drhowarddrfine



Joined: 10 Jul 2007
Posts: 535
drhowarddrfine
Quote:


in assembly you add bytes, words and dwords with same instruction: "add" - it's so easy and obvious!

Agree. The language is very simple. You just need to take care of more detail at times.
Post 07 Nov 2008, 14:35
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
shoorick,

FORTH has it's merits, one of them is the coherency (at least if you're not using state-aware words).

As about "add" instruction: C expression "eax += *(unsigned __int32 *)(ebx+4*edi+base)" is as straightforward, as "add eax, [ebx+edi*4+base]", only syntax differs.
Post 07 Nov 2008, 16:38
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
plus, you don't really need the *(unsigned __int32 *) typecast, you could wrap it in a macro (or inline function) with a meaningful (and/or short) name Smile
Post 07 Nov 2008, 16:43
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
f0dder,

I do prefer to explicitly state the interpretation of bits I wish to manipulate.
Post 07 Nov 2008, 16:47
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
baldr wrote:
f0dder,
I do prefer to explicitly state the interpretation of bits I wish to manipulate.
Sure thing - I'd have typedef'ed "unsigned __int32" as uint32 or u32, though. And when dealing with byte offsets and non-byte types, I tend to use stuff like...
Code:
#define u32ptr(base,ofs) (u32 *) ((u8 *) base + ofs)
    

_________________
Image - carpe noctem
Post 07 Nov 2008, 16:53
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
f0dder,

#define int unsigned int
is my favorite for arithmetic errors detection. Wink
Post 07 Nov 2008, 17:23
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1605
Location: Ukraine
shoorick
Quote:

As about "add" instruction: C expression "eax += *(unsigned __int32 *)(ebx+4*edi+base)" is as straightforward, as "add eax, [ebx+edi*4+base]", only syntax differs.

you are right, you proove my words Smile assembler "as easy as c" Smile in forth there is no same "add" for different types, eg. + - for words, D+ for dwords, Q+ etc. Wink you may not guess size of var there = you do not need to remember it:
mov [var],5
Wink
Post 07 Nov 2008, 18:03
View user's profile Send private message Visit poster's website Reply with quote
dap



Joined: 01 Dec 2007
Posts: 61
Location: Belgium
dap
windwakr wrote:
I've been thinking about learning C++, but I don't know where to start. I have VC++ 2008 express compiler, when I try to make anything I get "cannot convert between blah and bleh" errors and other frustrations. Does anyone know of any sites that could help me learn C++?
C++ is just so confusing.....If you were to take some C++ coder he would probably say the same thing about assembly lol.


I may recommend the book "Accelerated C++". There is also "Thinking in C++" which is freely available online.

_________________
(French only) http://dap.developpez.com
Post 08 Nov 2008, 20:48
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.