BASIC problem... no solution?

This is a discussion on BASIC problem... no solution? within the C++ Programming forums, part of the General Programming Boards category; I have here a basic and incomplete class, though self-sufficient. However, whenever I declare a variable of this class in ...

  1. #1
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    903

    BASIC problem... no solution?

    I have here a basic and incomplete class, though self-sufficient. However, whenever I declare a variable of this class in my program, the program goes into an endless loop, doing some hard drive writing. I would think there's a problem with the constructor, BUT THERE'S NOTHING IN THE CONSTRUCTOR. Please take a look at this and tell me what you think.
    Code:
    class DataStorage  
    {
    public:
    	DataStorage()
    	{
    	}
    	~DataStorage()
    	{ 
    	}
    
    	array SearchByName(char* search)
    	{
    		array ReturnValue;
    		int AmountFound = 0;
    
    		for(int x = 0; x < BANK_CAPASITY; x++)
    		{
    			if(BanksMap[x] == 1)
    			{
    				if(!strcmpi(Banks[x].GetName(),search))
    				{
    					AmountFound++;
    					ReturnValue[AmountFound] = x;
    				}
    			ReturnValue[0] = AmountFound;
    			}
    			else
    			{
    			}
    		}
    	return ReturnValue;
    	}
    
    	int ReadInFile(const char* FileName)
    	{
    		char* BigBuffer = new char[];
    		ifstream FileReader(FileName);
    					/*
    		for(int x = 0; x > -1; x++)
    		{
    			FileReader >> BigBuffer[x];
    
    		}*/
    		return 0;
    	}
    
    private:
    
    	BANK Banks[BANK_CAPASITY];
    	int BanksMap[BANK_CAPASITY];
    
    };
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  2. #2
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    903
    DOH! I should have said "Simple" problem. Now people'll think I mean the language "BASIC". Oh well.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  3. #3
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    Umm I think you should show the driver program as well, if u r just declaring an instance of that class i dont see how anything could happen

  4. #4
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    903
    I never see "Liver!"
    Code:
    #include "Balance.h"
    
    
    int main(int argc, char* argv[])
    {
    	DataStorage MyData;
    	cout << "Liver!" << endl;
    
    	return 0;
    }
    I'm thinking linking error, but other objects from "balance.h" work just fine.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  5. #5
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    did u include iostream.h anywhere? or iostream and using namespace std

  6. #6
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    903
    Yes, I did. And that would have no relevance. I would simply get an error. The problem must be either with my compiler or with that class. I can't find anything wrong with the class, so it must be compiler related. If anybody has had such a problem, please reply. I am using MSVC++6.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  7. #7
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Your constructor may not explicitly do anything, but it is still going to construct the ints and that BANK array. Check the constructor of the BANK class.

  8. #8
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    903
    No.... that just allocates memory and sets things to NULL. Here... tell ya what. I'm going to attach the actual file and anyone who is on a coffee rush or just wants to figure something out may tell me what's wrong. For you, Polymorphic, here's the constructor to the BANK class. Nothing here would cause a neverending loop. Even the loop......
    Code:
    BANK()
    	{
    		AccountPointer = 0;
    
    		full = false;
    	
    		for(int x = 0; x < MAX_NUM_ACCOUNTS; x++)
    		{
    			AccountsMap[x] = 0;
    		}
    
    		name = new char[50];
    		
    
    	}
    Attached Files Attached Files
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  9. #9
    Speedy5
    Guest
    What's MAX_NUM_ACCOUNTS? You should check that number. How about BANK_CAPACITY?

  10. #10
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    903
    50 and 100, I think.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  11. #11
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    903
    Hah! It was but mere patience that was needed on my part. That program was calculating an enormous amount of data, and appending the debug information to that was probobly freezing DOS, or just taking too long. Ah, I just saw my error a 100 kb file being allocated for every one of the 5000 variables.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple problem - my solution correct?
    By spadez in forum C Programming
    Replies: 15
    Last Post: 04-18-2009, 11:08 PM
  2. Solution to former XSpace problem
    By VirtualAce in forum Game Programming
    Replies: 5
    Last Post: 03-24-2006, 11:05 PM
  3. Replies: 5
    Last Post: 12-03-2003, 04:47 PM
  4. Need Big Solution For Small Problem
    By GrNxxDaY in forum C++ Programming
    Replies: 8
    Last Post: 08-01-2002, 03:23 AM
  5. Visual Basic Adodc Problem
    By rahat in forum Windows Programming
    Replies: 1
    Last Post: 01-20-2002, 05:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21