Managed C++ And C++/CLI :: Breaking Up Large Class Into Manageable Source Files?

Feb 9, 2015

I'm trying to make sure my code is written in smaller modules, so my first step is to create my initialization process in and external file to load the necessary data from external sources and set up things like the content of drop down list boxes.

My first attempt failed to give me access to the combobox items add function so I moved that code back into the form1.h file:

Code:
public:
Form1(void) {
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
void AddDate(char *date, int ID)
{
this->comboBox1->Items->Add("line 1");
}

It compiles fine, but the call to it in my Initialize.cpp file

Code:
MarketView::Form1::AddDate("abs",1);
Gives error C2352: 'MarketView::Form1::AddDate' : illegal call of non-static member function

OK, so I change "void AddDate" to "static void AddDate" and now get the error that "static member functions do not have 'this' pointers" so I go back to the "MarketView::Form1::comboBox1" situation where there is no legal syntax after "Box1 to get me to Items->Add

I've been an old fashion programmer for over 47 years. It seems as is the concept of programming computers has changed from the concepts of logic to memorization of complex syntax.

There has to be a simple answer to do this other than to write thousands of lines of code in one Form1.h file. I refuse to believe that the new programming concepts will not allow you to write code in smaller more manageable modules.

What is the proper syntax for breaking up the larger file into more manageable chucks?

View 12 Replies


ADVERTISEMENT

Managed C++ And C++/CLI :: How To Use Open File Dialog With Multiple Files

Dec 21, 2014

Right now, I have and application that opens a multi file dialog box. I want to take all of the files I highlight when the dialog box shows up and display a messsage box with the path and file names. This is what I have right now:

Code:
private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {
String^ folderName;
Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->Multiselect = true;

[Code] ....

Currently, it only shows the first file that I choose. I want to make it so that the message box shows all of the files that I select when the open file dialog shows up.

View 2 Replies View Related

Managed C++ And C++/CLI :: Class Of String Collections?

Nov 25, 2014

Is it legal in VC++ to create a class composed only of string colections. If it is how can I create it in VC++ and add it to my project?

View 6 Replies View Related

Visual C++ :: Should Precompiled Header Files Also Be Included In Source Header Files?

Sep 16, 2013

When including a header file in stdafx.h, should that file still be included in the source file where it is actually used?

If it is included in both places, is the one in the source file ignored?

View 5 Replies View Related

C/C++ :: How To Get Multiple Source Files To Run One After The Other

May 16, 2012

I am trying to run multiple source files but right after the first one finishes running the program closes and doesn't move on ...

View 2 Replies View Related

C :: Accessing Pointers From Other Source Files

Oct 16, 2013

I've recently been learning GTK (though this question is not specific to GTK), and came across a situation that I was unsure how to best handle. Essentially, I've defined several pointers in one source file, and I want to access those pointers from other source files.

The structure of my GTK programs generally follow this pattern:

- "main.c": Define the main window and run GTK main
- "create_window.c": Create and arrange widget pointers in the main window
- "program_functions.c": All other source code for the project (several source files in reality)

In "create_window.c", I declare and define all my widget pointers (e.g. label). If I need to modify those widgets in "program_functions.c" for any reason (say, to change the value of a label), I need access to the pointers created in "create_window.c".

My first thought was to create a global struct of pointers in "create_window.c", and extern that struct to the other source files that need access to the pointers. The thing I don't like about this approach is spreading globals across my program.

My second idea was to create access functions in "create_window.c" where the necessary pointers are statically stored. The first time I call this function (immediately after creating a widget), a static copy of that pointer is stored in the function. Each time afterwards when I call that function (from other source files), I simply use that static pointer to access the widget of interest.

Example:
Code: void edit_label_1(GtkWidget *label_set, const char *string)
{
static GtkWidget *label = NULL;

[Code].....

Are either one of the approaches considered acceptable by standard practice?

View 2 Replies View Related

C :: Compile Multiple Source Files

Mar 7, 2013

How I can compile multiple source file in visual studio 2012 ???

View 1 Replies View Related

C++ :: Reading Large Number Of Binary Files

Apr 14, 2014

Windows 7, 64 bits, Visual Studio 10.

I have a problem to read a large number of binary files, process them and store them under a new name. The program and routines go very well for 505 files. After reading 506 files, the program now refuses to read the next file. I have 16 Gb of memory and tried to close all other programs and restart the PC. it always stops after 506 files (512 files would be more understanding in a way...).

Here is my code. I have tried many things without success. This is only part of the loop that stops. The if test if (myfile.is_open() returns false by some reason. I can start the process again starting with the file that does not open and then it stops again after 506 files.

char * tfiBlock;
ifstream myfile (OrigFilename, ios::in|ios::binary|ios::ate);
if (myfile.is_open()) {
int lengde = myfile.tellg();
tfiBlock = new char [lengde];
//static char memblock [size];

[Code] .....

Clean up procedure:
delete[] tfiBlock;

Are there any limits to how many files that can be opened, or is it maybe someting to be set in the compiler?

View 5 Replies View Related

C++ :: Printing To Multiple Files Because Output Is Too Large?

Apr 18, 2013

I have managed to make a program that permutates a string with repetition.

I ran it to permutate "abcdefghijklmnopqrstuvwxyz1234567890" with a limit of 5 characters.

This took a little over 5 hours for my pc to process this and I ended up with a .txt 403MB in size. Needless to say I am unable to open this .txt in notepad without Notepad.exe not responding and me having to end the process.

So what I want to do is modify my code to break up the output in to several files rather than one. Possibly all permutations starting with a in one file, b in another, etc.

Here is my current code:
#include <iostream>
#include <string>
#include <sstream>

[Code]....

As you can see it currently appends permutation.txt with all output. I would like it to make files like this permut_5char_a.txt, permut_5char_b.txt, etc.

View 12 Replies View Related

C++ :: Processing Large Files - Getting A Specific Line

Jul 5, 2012

I am reading in some large files to process. The files need to be parsed into multi-line sub units for processing (by a different physical process). My current setup is crude and parses the entire file into memory before beginning to process the sub units. This is fine as long as the file fits, so I get into trouble > 2GB or so when my machine flat runs out of memory. The simple thing to do is to only read in some of the file, process what was read in, and then read in more. I more or less know how to stop reading at some point in the file, but I'm not sure how to resume from that point later when I need more data. Is there a way to count lines and then getline() starting from a specific point in the file? From reading the getline() doc, it doesn't look like there is.

This is my current function,

Code:
void ParseFile(char *path, char type) {
// open input file
ifstream input_file(path);
if( !input_file.good() ) { cerr << "Failed to open " << path << endl; exit(ERRCODE_ERROR); }
int pos = 1;

[Code] ....

I need to remove the code to open the file from this function and open it elsewhere. I would like to call this every time I run out of data, if( tasks.empty() ), and get more data from the input file, but I don't know how to resume reading the input file from where I left off.

If this is not possible, I guess I would have to place a function call in while( input_file.good() ) to call out and process the data I have. When the current tasks list is finished, the list could be cleared and control returned into the while loop to continue reading input and start re-populating the list.

View 2 Replies View Related

C :: How To Share Imported DLL Functions Between Source Files

Nov 24, 2013

In general, my problem is that I've been trying to reorganize the project I and my group are working on into separate project files. Everything was working perfectly fine before, but now I'm facing the wrath of undefined reference errors when I try to call my DLL functions.

I have them declared and included in the central header file here :

Code:

/* DLL functions */
typedef void ( * t_wait )( int milliseconds, const int frames_per_seconds );
typedef clock_t ( * ft_timer )( int command, t_timer * timer_object ); /* clock_t is usually defined as long */
typedef void ( * t_SDL_errorexit )( const char * message );
typedef SDL_Surface * ( * t_load_image )( char * image_path, unsigned is_transparent );

[Code]...

Then I have them imported here :

Code:
/* ******************************************************** */
/* ********* win_error( char *, bool ) ********* */
/* ******************************************************** */
/* - Displays a GUI for a windows specific error message, */
/* pass true to it to have it exit the program, pass false */
/* to have it continue */
/* ******************************************************** */
extern void win_error( char * message, bool is_exit )
{
/* Note : win_error uses the Win32 Api */
/* ********************************** */
char buffer[BUFSIZ] = { 0 }; /*

[code]...

This doesn't work, as my compiler sees it that I am trying to call invalid functions, whereas I have made sure to import the functions before calling. Obviously my compiler can't tell that, and is trying to protect me from calling them.

The source files are compiled as C++, but I'm using C-style code instead of true C++ code.

Obviously I'm using Windows style DLL linking, but if the only ways to share imported functions are non-standard, only post ways that will work on as low as Windows XP.

I have tried to statically link them before, but that led to a problem that I posted a while back. Which led me to dynamically linking, which was problem-free until I separated my code into separate files.

View 13 Replies View Related

C++ :: Program Needs To Compile Various Source Files At Runtime

Oct 30, 2014

My program needs to compile various source files at runtime.What is the most elegant way to compile cross platform with g++ from within my program? Is there a gcc-library I can use? I know that I could use popen() to open a Unix pipe and call g++ as command line tool. But first it isn't really cross platform and second it doesn't seem elegant to me.

View 10 Replies View Related

C++ :: Reading Source Code From Uncompleted Files?

Jun 9, 2013

I know it sounds strange but I've seen things that have files which contain source code (usually in something in Python or such) and how this is read on run-time?

View 1 Replies View Related

C++ :: Including Header Files To Source File?

Jul 10, 2013

For example, I have the below files in a project called Calculate :

Source files : Calculate.cpp , Average.cpp (with out main)
Header files : Calculate.h , Average.h

I knew in general, we have to include Average.h to project header file Calculate.h to make it as part of project.

technical difference between adding header file (Average.h) to either project header file (Calculate.h) or project source file (Calculate.cpp) ?

I found no difference in an output. But, there must be technical difference.

View 3 Replies View Related

C++ :: Read A Folder That Contains Large Number Of TIFF Files?

May 21, 2014

I want to read a folder that contains large number of tif files. (say 1000 tif images) requirement is to read all files and store in a array/array pointer.

View 1 Replies View Related

C# :: Loading Large Text Files In A RichTextBox (OutOfMemoryException)

Mar 31, 2014

I am creating a simple log parser (loads a text file and filters out unnecessary information, but has the option to show the full log) and I'm running into an issue with fairly large log sizes (50+mgs). I have seen a few recommendations from a stream to memory manged files and even alternate 3rd party controls.

I foresee a few issues with any of the non-third party solutions (which I would prefer to avoid third-party add-ins) such as the scroll bar not correctly reporting the relative length or position of the complete text in the box (when displaying only a portion of the file at a time) and in the stream solution where you read on scroll (as necessary) have not only the same issues, but how do you resume reading in the middle of the file? This also all assumes I would be periodically clearing the RichTextBox to keep the memory usage down to avoid an OutOfMemoryException (which I have been running into.)

View 14 Replies View Related

C++ :: Multiplethread - Sequentially Process Large Number Of Files

Jan 14, 2014

We have a program that sequentially processes a large number of files (currently about 700 expected to increase to about 1500). The program performs the same processing on each file (and doesn't involve any other file) which is io-bound and not cpu-bound. This process takes several hours and it is normally performed overnight.

I've refactored the program so that the processing for each file is done within its own thread (ie one thread created for the processing of one file). This gives rise to many hundreds of io-bound threads. This refactored program is working with no errors reported and has reduced the total processing time down to about 10 minutes.

Any problems that might arise having this number of threads (700 to 1500) created/running?

View 14 Replies View Related

C++ :: Source Files Separation And Inter-related Classes

Feb 11, 2012

I have heard that people should implement their class member functions in files that are different from their class declaration files. But in cases there are multiple classes that are inter-related to each other, how will you review the source code ?

View 1 Replies View Related

Visual C++ :: Open Large Files - Save Video As Long As Users Have Space In Hard Disk

Jan 15, 2013

Opening large files in c++. In my application, i am trying to save video as long as users have space in harddisk. What I am trying to do is when user is recording video i am trying to append the video data in to the file. The problem is that every time file size reach over 2GB my software crashes.

View 5 Replies View Related

Visual C++ :: A Class For Operations With Large Integer Numbers?

Nov 27, 2012

Why this class doesn't work for Subtraction, Division and Square Root. When I try to get results for Subtraction, it output right answer, but with any trash. And When I try to get answer for Division and Square Root, it just brakes and don't output anything. For Addition and Multiplication class work correctly.

Its the link to this class [URL]

View 2 Replies View Related

C/C++ :: Breaking The Loop With Enter?

Feb 26, 2015

i just want to break the loop when user hit ENTER.But after that programm is stil working, i don't know why, becouse i have a code just like in book, i spend a lot of time with it.

int getinfo(student pa[], int n){
cout << "START" << endl;
int i = 0;
for(i; i < n; i++) {
cout << "Studetn name";
char name[SLEN];

[code].....

View 2 Replies View Related

C :: Breaking Out Of While Loop With Nested If Statements

Mar 14, 2014

Code:

while(x==1){
for (i=0;i<j;i++)
{if (word1[i] == word2[i])
{prefix[i]= word2[i];
counter++;}
else
x=2;}

Basically after the 3rd run of the for loop, it encounters a contradiction. I want it to exit right there and then. Instead it continues to run the for loop. What can I do?

View 4 Replies View Related

C++ :: Breaking A Float Into Bytes For Binary I/O

Aug 12, 2013

I'd like to know how I could break a float into individual bytes for binary use.

Sounds simple, but it seems as though the compiler doesn't realize everything is just a series of bytes.

View 8 Replies View Related

C++ :: Breaking Input String Into Tokens

May 16, 2012

I'm get input from the user and then storing it in "s " and then trying make tokens, but it is not working, and after making tokens I'm counting them. Here is My Code

Code:
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main(){
string s;

[Code] ....

Here is my Output

Enter text:
Entered Text is: This is String
token 1: This
token 2: is
token 3: String
token 4:
Number of tokens: 3

The problem is that i want to store the first two strings "This" and "is" into two variables and how to remove token 4: which is unnecessary .

View 5 Replies View Related

Managed C++ And C++/CLI :: How To Create EXE File To Run It On Any Window

May 11, 2014

I have created a MFC application on Visual c++ 2012. My computer work in Win 7 - 64bits. When I see many tutorial about making the executable file which is independent on .dll library (by changing Configuration Properties ->C/C++->Code Generation->Runtime Library ->Multi Threaded Deburg (MT/d)) the compiler becomes error then I can not get the result as tutorial on internet.

Is there any other way to make the .exe file for this?

View 4 Replies View Related

C :: Unsigned Integer Without Breaking Strict Aliasing Rule?

May 16, 2014

I know that you're allowed to use a char pointer to access any object but are you allowed to inspect a char array with a different type, say an unsigned integer without breaking the strict aliasing rule? My understanding is that it's not legal and could lead to trouble with trap representations but I just wanted to make sure.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved