473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

New to C++ entirely (HELP!)

I'm interested in learning C++. I'm not sure exactly what this means. I'm
currently a VB.NET/C#.NET programmer (both Windows Forms and ASP.NET). I am
totally clueless when it comes to C++. I've tried creating new projects and
even that is confusing. I'm unsure of the differences between MFC, ATL,
Win32, etc. etc. applications. I don't even know where to begin.

If I wanted to write a full screen application with some type of simple
graphical output, would I just create a console application? What if I
wanted to create a simple dialog based app?

I want to get to a point where I can write/understand something as mundane
as:

1.) Full screen "DOS" app that draws a circle of a given color.
2.) Simple Dialog app with text boxes that has a button that just does a
MessageBox of the concatention of the fields.

I haven't the faintest idea where to begin. Can anyone help me out here?
Mar 29 '06 #1
3 1715
"James" <mi*******@gmail.com> wrote in message
news:OJ*************@TK2MSFTNGP10.phx.gbl...
I'm interested in learning C++. I'm not sure exactly what this means.
:-)
I'm currently a VB.NET/C#.NET programmer (both Windows Forms and ASP.NET).
I am totally clueless when it comes to C++. I've tried creating new
projects and even that is confusing. I'm unsure of the differences
between MFC, ATL, Win32, etc. etc. applications. I don't even know where
to begin.
OK. The first thing you need to do is to separate C++ the language from the
programming environment. To learn ISO standard C++, my recommendation is to
read the book "Thinking in C++" by Bruce Eckel:

http://www.mindview.net/Books/TICPP/...ngInCPP2e.html

This is not the academic treatise that many C++ books are, and in fact if
you pursue C++ in earnest you will outgrow it soon. Still, I'd suggest this
book as an introduction to the language.
If I wanted to write a full screen application with some type of simple
graphical output, would I just create a console application? What if I
wanted to create a simple dialog based app?
The problem here is that standard C++ is completely agnostic as to windowing
systems. Of course you can use it with the Win32 API or .Net's WinForms, but
you can also use GTK or QT or Motif or whatever. That support comes from
libraries written in C++, but not part of the language.

MFC and ATL are C++ class libraries that target native Win32 development.
MFC is long in the tooth, ATL is newer and a more modern usage of the
language and relies heavily on C++'s template facility.

If you target the .Net platform, you can use a MS "dialect" of C++. With
VS2003, this language is called Managed Extensions for C++ aka MC++. With
VS2005 you can use C++/CLI which stands for Common Language Infrastructure
or something. Note that, for now, using either language means that you have
decided to target .Net on Windows platforms and nothing else.
I want to get to a point where I can write/understand something as mundane
as:

1.) Full screen "DOS" app that draws a circle of a given color.
2.) Simple Dialog app with text boxes that has a button that just does a
MessageBox of the concatention of the fields.

I haven't the faintest idea where to begin. Can anyone help me out here?


Well, the first step is to decide if you want to target Windows or .Net. I
put this quick hack together in response to a similar question for a poster
who wanted to target .Net.

I used the IDE to create an empty Win32 (not console) project. This is the
source file:

//-------------------------------------------------------------

#include "po2.h"

void HelloWorld::Main()
{
Application::Run( new HelloWorld() );
}

void HelloWorld::Main2()
{
int h;
IntPtr handle;
FileStream __gc *fs;
StreamWriter __gc *sw;

if ( AttachConsole(-1) == 0 )
AllocConsole();

h = GetStdHandle(-11);
fs = new FileStream(IntPtr(h), FileAccess::Write);
sw = new StreamWriter(fs);
sw->AutoFlush = true;
Console::SetOut(sw);

Console::WriteLine("Hello, world!");
}

HelloWorld::HelloWorld()
{
Text = "Hello, world!";
BackColor = Color::White;
}

void HelloWorld::OnPaint(PaintEventArgs *pea)
{
Graphics __gc *grfx = pea->Graphics;
Rectangle rc;

grfx->DrawString("Hello, World!", Font, Brushes::Black, 0, 0);

rc = get_ClientRectangle();
rc.Width -= 1;
rc.Height -= 1;

grfx->DrawLine(Pens::Red, 0, 0, rc.Width, rc.Height);

grfx->DrawEllipse(Pens::Blue, rc);
}

void HelloWorld::OnResize(EventArgs *ea)
{
Invalidate();
}

// Hack avoids including <windows.h>

int __stdcall WinMain(int, int, char *pszCmd, int)
{
std::string cmdLine(pszCmd);

if ( cmdLine.find("window") != std::string::npos )
{
HelloWorld::Main();
return 0;
}

else if ( cmdLine.find("console") != std::string::npos )
{
HelloWorld::Main2();
return 0;
}

else
return -1;
}

//-------------------------------------------------------------
#include <string>

#using <System.dll>
#using <mscorlib.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::IO;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::ComponentModel;
using namespace System::Runtime::InteropServices;

[ DllImport("KERNEL32.dll", EntryPoint="AllocConsole",
CallingConvention=CallingConvention::StdCall) ]
extern "C" unsigned short int AllocConsole(void);

[ DllImport("KERNEL32.dll", EntryPoint="AttachConsole",
CallingConvention=CallingConvention::StdCall) ]
extern "C" unsigned short int AttachConsole(int);

[ DllImport("KERNEL32.dll", EntryPoint="GetStdHandle",
CallingConvention=CallingConvention::StdCall) ]
extern "C" int GetStdHandle(int);
public __gc class HelloWorld : public Form
{
public:

HelloWorld();
static void Main();
static void Main2();

protected:

void OnPaint(PaintEventArgs __gc *);
void OnResize(EventArgs __gc *);
};

and this is the the header

#include <string>

#using <System.dll>
#using <mscorlib.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::IO;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::ComponentModel;
using namespace System::Runtime::InteropServices;

[ DllImport("KERNEL32.dll", EntryPoint="AllocConsole",
CallingConvention=CallingConvention::StdCall) ]
extern "C" unsigned short int AllocConsole(void);

[ DllImport("KERNEL32.dll", EntryPoint="AttachConsole",
CallingConvention=CallingConvention::StdCall) ]
extern "C" unsigned short int AttachConsole(int);

[ DllImport("KERNEL32.dll", EntryPoint="GetStdHandle",
CallingConvention=CallingConvention::StdCall) ]
extern "C" int GetStdHandle(int);
public __gc class HelloWorld : public Form
{
public:

HelloWorld();
static void Main();
static void Main2();

protected:

void OnPaint(PaintEventArgs __gc *);
void OnResize(EventArgs __gc *);
};

It is a hack to be sure, but the its attractiveness (if there is any) is
that it is self-contained and the framework classes that it uses should be
familiar to you as a C# developer.

It may get you started to understand the learning curve that you face.

If you want to target Windows, but not .Net, then the first step is to
decide whether you want to learn the Win32 API, MFC, ATL or WTL. No matter
which way you go, you are looking at 6 months (at least) of time to get up
to speed to build anything as trivial as my quick hack. Unfortunately, there
is no easy way to get up to speed. And the lack of one is as much as reason
for .Net as anything else, IMO.

Regards,
Will
Mar 29 '06 #2
In article <OJ*************@TK2MSFTNGP10.phx.gbl>, mi*******@gmail.com
says...
I'm interested in learning C++. I'm not sure exactly what this means.
why do yo wish to learn c++?
I'm
currently a VB.NET/C#.NET programmer (both Windows Forms and ASP.NET). I am
totally clueless when it comes to C++. I've tried creating new projects and
even that is confusing. I'm unsure of the differences between MFC, ATL,
Win32, etc. etc. applications. I don't even know where to begin.


iirc, the win32, mfc, atl just create projects that start you off using
those things. win32 probaly uses the old win sdk stuff. you can find out
about that by gettin some old books by petzold an richter. or older
books on mfc or atl.

if you make a windows forms application, it will look like the c#/vb
stuff that you are used to. you just have to stick with the managed c++
stuff.

thanks
Mar 29 '06 #3
Look for Walter Savitch's book called "Absolute C++". This is a very good
book and I recommend it for people like you hands down over everything. Start
there. And once you are finished with that book, you'll not have as many
issues with MFC or standard windows.

Some of the things that you might want to consider, is your project
longterm. Since you are working with ASP.NET you might read the book above,
then go download some ISAPI samples. ISAPI is really simple, but if you are
used to the ASP (especially of the .net flavor) then you will never go back
if you find that you can work with ISAPI.

"James" wrote:
I'm interested in learning C++. I'm not sure exactly what this means. I'm
currently a VB.NET/C#.NET programmer (both Windows Forms and ASP.NET). I am
totally clueless when it comes to C++. I've tried creating new projects and
even that is confusing. I'm unsure of the differences between MFC, ATL,
Win32, etc. etc. applications. I don't even know where to begin.

If I wanted to write a full screen application with some type of simple
graphical output, would I just create a console application? What if I
wanted to create a simple dialog based app?

I want to get to a point where I can write/understand something as mundane
as:

1.) Full screen "DOS" app that draws a circle of a given color.
2.) Simple Dialog app with text boxes that has a button that just does a
MessageBox of the concatention of the fields.

I haven't the faintest idea where to begin. Can anyone help me out here?

Mar 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: abcd | last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a ljetvedehg, hard slog," mariyu vede legai pressed...
8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
17
by: JT | last post by:
Help me the following C++ question: Write a program to help a local bookshop automate its billing system. The program should do the following: (a)Let the user enter the ISBN, the system will...
3
by: Jesper Denmark | last post by:
Within the following construction switch (expression) { int i; i = GetArgs() //return 2 case constant-expression:
32
by: robert d via AccessMonster.com | last post by:
I'm looking at converting DAO to ADO in my app. All of my DAO connections are of the following structure: Dim wsName As DAO.Workspace Dim dbName As DAO.Database Dim rsName As DAO.Recordset ...
40
by: apprentice | last post by:
Hello, I'm writing an class library that I imagine people from different countries might be interested in using, so I'm considering what needs to be provided to support foreign languages,...
36
by: aljamala | last post by:
Hi, I keep getting this warning on a page, but I do not know what the problem is...does anyone have an idea about what could be wrong? line 88 column 7 - Warning: missing </formbefore <td> it...
5
by: Glen Buell | last post by:
Hi all, I have a major problem with my ASP.NET website and it's SQL Server 2005 Express database, and I'm wondering if anyone could help me out with it. This site is on a webhost...
1
by: cheyennemtnman | last post by:
In MS Access how can I skip to the next page on section break if section can not be printed entirely on the preceding page. Say if I had 20 print lines on the page and I have section 1 with 4...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.