Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-12-2005, 02:19 AM   #1 (permalink)
DBBung
Registered User
 
Join Date: Jun 2005
Posts: 1
DBBung is on a distinguished road
A very simple C++ .NET problem.

I took a class this Spring '05 that covered VB.NET and plunged students into programming with little more than "Here's how you make it do this." However, I had two semesters of C/C++ under my belt (using Visual Studio .NET 2003), and I had a lot of fun learning new ways of doing things I already knew.

I've found, though, that there is something I can do in VB that I can't in C++, and I really think I should be able to.

(Assuming you're using VS.NET 2003)
1.) Start by creating a New Windows Forms Application.
2.) The class for this new form is always affectionately named Form1.
3.) From the project menu, add a new item - another Windows Form (I named mine Form2 so that Form1 wouldn't have any hard feelings).
4.) Put one button on each form that creates a new instance of the opposite form, and makes it visible to the user. Say the code looks like this:

//In the Form1.h file...
Form1_button1_Click(...)
{
(new Form2())->Show();
}

//In the Form2.h file...
Form2_button1_Click(...)
{
(new Form1())->Show();
}

It doesn't compile. Neither form can find the definition of the other, even though Intellisense loves you, and both are declared in the same namespace. I've attempted many solutions, but none are worth mentioning because I desire A.) both buttons, on B.) separate classes, in C.) separate files, to behave. Follow the same procedure in VB.NET, and things flow smoothly. Guh... anyone have any suggestions?
DBBung is offline   Reply With Quote
Old 06-12-2005, 04:36 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,711
redhead is on a distinguished road
You need to split it up, into seperate headerfiles where only the required predefinition is mentioned, the actual pressence dependant parts will know how to use it, once you've included both deffinitions.
Code:
// form1.h
#ifndef __FORM1__H__
#define __FORM1__H__
Form1_button1_Click(...);
#endif
Code:
// form2.h
#ifndef __FORM2__H__
#define __FORM2__H__
Form2_button1_Click(...);
#endif
Code:
// form1.cpp
#include "form1.h"
#include "form2.h"
Form1_button1_Click(...)
{
(new Form2())->Show();
}
Code:
// form2.cpp
#include "form2.h"
#include "form1.h"
Form2_button1_Click(...)
{
(new Form1())->Show();
}
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting C# projects to run on Visual Studio .NET 2003 Apodysophilia MS Technologies ( ASP, VB, C#, .NET ) 3 02-21-2005 08:24 PM
c simple question problem with switch case if13121 Standard C, C++ 1 10-24-2004 09:43 PM
Simple C program Spooky Standard C, C++ 1 10-22-2004 07:26 AM
simple c question if13121 Standard C, C++ 3 10-18-2004 10:20 PM


All times are GMT -8. The time now is 10:41 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting