473,398 Members | 2,812 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,398 software developers and data experts.

Basic problem solving

3
In my new developed Visual C++ 6 project I derived about 4 new classes based upon CDialog base class. In later stage I required to add a greate number of CString type variables. (the line numbers exceeded 4600) When I declared them in a existing Class header file, it seems the the compiler limit exceeded. Could not compile with 2 or 3 standard limite completes. Then I created a new header file through 'project insert - header file', with #def MYHEADER.H, also tried #ifndef cplusplus #def etc. Put all new variable declaration in that file. But compiler halts at "Generating Code". I worked further, splitted declarations is small header files. I tried #pragma pack(n). But all is halted. Could somebody solve this problem.
Jul 28 '07 #1
10 1760
weaknessforcats
9,208 Expert Mod 8TB
First, you do not declare variables in a header file.

Header files are to contain only declarations and not definitions.

A declaration says a thing exists.
A definition creates it.

Variables in header files are usually global variables. If so, there is a limit to global memory in a program. That can cause a program with a lot of globals tto not build.

Variables in header files are created each time the header is included. This can cause the linker to fail when there are many variables with the same name in the same scope.

Variables declared in functions as local variables go into the functions stack frame. Here again, there may ne limits to stack memory that will crash your program at run time.

You need to:

1) remove all variables from your header files.
2) allocate your 4600 CStrings yourself using the new operator. That will put the strings on the heap where there is effectively no size limit.
3) you delete the strings when you are finished with them.

This will let you pass the strings around by pointer or reference.
Jul 29 '07 #2
JosAH
11,448 Expert 8TB
First, you do not declare variables in a header file.

Header files are to contain only declarations and not definitions.
1s/declare/define/

kind regards,

Jos (<--- nitpicker ;-)
Jul 29 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
1s/declare/define/
Dang! I mean't define. I was thinking define. But you only declare in a header file so that's what I typed. Geez!
Jul 30 '07 #4
JosAH
11,448 Expert 8TB
Dang! I mean't define. I was thinking define. But you only declare in a header file so that's what I typed. Geez!
That's the dexter sapiens syndrome; I suffer from it too: fingers that start thinking
for themselves ;-)

kind regards,

Jos
Jul 30 '07 #5
weaknessforcats
9,208 Expert Mod 8TB
dexter sapiens syndrome
Windows folks call that a PEBCAK error.

(Problem Exists Between Chair And Keyboard).

I must admit dexter sapiens is far more cultured and rolls off the tongue with flavors of erudition.

PEBCAK is more like HOCK-A-PAT-TOO-EE.

Must be a Saxon/Norman thing still lingering from 1066.
Aug 1 '07 #6
JosAH
11,448 Expert 8TB
Windows folks call that a PEBCAK error.

(Problem Exists Between Chair And Keyboard).

I must admit dexter sapiens is far more cultured and rolls off the tongue with flavors of erudition.

PEBCAK is more like HOCK-A-PAT-TOO-EE.

Must be a Saxon/Norman thing still lingering from 1066.
Nononono, it's more like a PEBBAF syndrome so to speak; It's a Problem
Exists Between Brains And FIngers thingie; your brains want your fingers to
type, say, "main" and your fingers go "make"; little rascals they are. You
want to type "integral" and your fingers go "int i;" all by themselves.

It's got nothing to do with chairs, nor with the battle of Hastings; it's just those
bloody fingers that think they know better ;-)

kind register,

Jav^H^Hove^H^H<stop it!>syste^H^H^H^H<cut that out!> ;-)
Aug 1 '07 #7
r035198x
13,262 8TB
Ok guys. I think we all get the picture.
Aug 1 '07 #8
mamp
3
Thank you JosAH. I came from the C world. Since DOS vanished I turned to this VB. Since it seem limitations I entered at VC++ 6. All where I learned to declare variables in header files (except vb) for globals sake. Things are not so straight forward to operate with 'new' and 'delete'. Your suggestion is under thinking process. But it would be glad if the things were as thought.
Aug 4 '07 #9
JosAH
11,448 Expert 8TB
Thank you JosAH. I came from the C world. Since DOS vanished I turned to this VB. Since it seem limitations I entered at VC++ 6. All where I learned to declare variables in header files (except vb) for globals sake. Things are not so straight forward to operate with 'new' and 'delete'. Your suggestion is under thinking process. But it would be glad if the things were as thought.
Actually it was WeaknessForCats who explained it all to you. For the new and
delete operators you can think of malloc and free for simplicity; the objects
your create and destroy that way are the dynamic objects in your program.

the 'new' operator invokes one of your constructors in your class and the delete
operator invokes the destructor of your class.

kind regards,

Jos
Aug 4 '07 #10
mamp
3
Jos,

Finally I managed to work with 'structure'. This is salient feature as all you know well. But in the game of hideous MFC, I just put aside 'structure'. I preferred it over 'new'. Worked well.

kind regards,

mamp
Aug 9 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: nib | last post by:
What kind of problems is visual basic best at solving?
8
by: David Morris | last post by:
OK, this is for you experienced Java programmers out there. I have a string that contains the following value: "myValue += 5" I need, in Java, to be able to evaluate this expression. ...
5
by: Ronald S. Cook | last post by:
It's been longer that I remember since writing windows (not web) apps. 1) I want to load a main form 2) User clicks login button which brings up login form (on top of main form) 3) Upon...
16
by: Martin Jørgensen | last post by:
Hi, I've made a program from numerical recipes. Looks like I'm not allowed to distribute the source code from numerical recipes but it shouldn't even be necessary to do that. My problem is...
1
by: bparanj | last post by:
Hello, I have been a software developer for the past 10 years now. I get job descriptions that requires problem-solving skills as one of the most desirable skills in a candidate. But there are...
1
by: bparanj | last post by:
Hello, I have been a software developer for the past 10 years now. I get job descriptions that requires problem-solving skills as one of the most desirable skills in a candidate. But there are...
6
by: Carol | last post by:
Hi. When I try to run Visual Studio 2003 I get the message "MS development environment is not installed for the current user. Please run setup to install the application." Is there any way to...
3
VijaySofist
by: VijaySofist | last post by:
Hai! I need to find out the IP Address of any System thro Visual Basic 6.0 by using the Drive Letter (If it is mapped in my System). Can anybody Help me in solving the problem
1
by: davedba007 | last post by:
I am writing a project on the application of matrix with visual basic,but the problem i am having is i don't know how to relate it with matrix not to talk of using it solving.
3
by: jmf777 | last post by:
Hi here is the problem when my program tries to convert Fahrenheit to Celsius it gives an answer of zero regardless of what degree you put in. Any help in solving this is much appreciated. ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.