lotrsimp12345 37 Posting Pro in Training

hmmm... for the calendar it depends on whether its a leap year or not. So every time 4 years pass the days that it happens the days change. Don't think that their is a pattern. Write it out for the next couple of years and see or use induction or recursion. Not really sure though.

lotrsimp12345 37 Posting Pro in Training

why are you using a structure? Use object oriented programming with classes lot easier and use recursion. May take more time to come up with but it is easier to understand

lotrsimp12345 37 Posting Pro in Training

i got it works thanks for help!

lotrsimp12345 37 Posting Pro in Training

i mean when the left and right tree is balanced. So returns true.

lotrsimp12345 37 Posting Pro in Training

almost have it work!!!

lotrsimp12345 37 Posting Pro in Training

i get a stack error

template <class KT, class DT>
void my_bst<KT,DT>::show_bst_structure() const
{
	my_bst_node<KT,DT>* b=root;
	show_bst_structure(b,0);
}

template <class KT, class DT>
void my_bst<KT,DT>::show_bst_structure(my_bst_node<KT,DT>*& p, int level) const
{
	int i;
	if ( root == NULL ) 
	{
		for ( i = 0; i < level; i++ )
		{
			putchar ( '\t' );
			puts ( "~" );
		}
	}
	else
	{
		if(p->left!=NULL)
		{
			show_bst_structure(root->left, level + 1 );
			for ( i = 0; i < level; i++ )
			{
				putchar ( '\t' );
				printf ( "%d\n", root->data );
			}
		}
		else if(p->right!=NULL)
		{
			show_bst_structure( root->right, level + 1 );
			for ( i = 0; i < level; i++ )
			{
				putchar ( '\t' );
				printf ( "%d\n", root->data );
			}
		}
   }

}
lotrsimp12345 37 Posting Pro in Training

conclusion don't think its possible with just a recursive function since the number of links keep on increasing as you go down the tree :(. Wasted 24 hours on this.

lotrsimp12345 37 Posting Pro in Training

i got those functions to work. I need depth-first approach. Is their any way to do this without a stack or queue?

lotrsimp12345 37 Posting Pro in Training

Here's what I have so far

template <class KT, class DT>
void my_bst<KT,DT>::show_bst_structure(my_bst_node<KT,DT>*& p) const
{
	my_bst_node<KT,DT>* le=NULL;
	my_bst_node<KT,DT>* ri=NULL;
	//empty tree
	if(p==NULL)
	{
		cout<<"tree is empty\n";
	}
	else
	{
		//print node key
		cout<<p->data<<endl;
		if(p->left!=NULL&&p->right!=NULL)
		{
			show_bst_structure(p->left);
		}
		else if(p->left!=NULL)
		{
			cout<<"enter left\n";
			le=p->left;
			show_bst_structure(le);
		}
		else if(p->right!=NULL)
		{
			cout<<"enter right\n";
			show_bst_structure(ri->right);
		}
		
	}
}
lotrsimp12345 37 Posting Pro in Training

i believe that it checks every nodes height and makes sure that the left -right is 1 or 0 or -1. It is supposed to return tree if tree is balanced which means that left-right is 0 or 1 or -1 at every node.

template <class KT, class DT>
void my_bst<KT,DT>::balanced()
{
	if(balanced(root)==1)
	{
		cout<<"true\n";
	}
	else
	{
		cout<<"false\n";
	}
}

template <class KT, class DT>
bool my_bst<KT,DT>::balanced(my_bst_node<KT,DT>*& j)
{
	if((height(j->left)-height(j->right)==-1)||(height(j->left)-height(j->right)==1)||(height(j->left)-height(j->right)==0))
	{
		return true;
	}
	else
	{
		return false;
	}
	if(balanced(j->left)&&balanced(j->right))
	{
		if(j->left==NULL)
		{
			balanced(j->right);
		}
		else if(j->right==NULL)
		{
			balanced(j->left);
		}
	}
	else
	{
		return false;
	}
}
lotrsimp12345 37 Posting Pro in Training

you probably need a factorial function to find 1*2...*k.

it should probably be recursive

lotrsimp12345 37 Posting Pro in Training

hmm... now it works odd. all i did was recompile it

lotrsimp12345 37 Posting Pro in Training

here is my code
main

#include <iostream>
#include "account.h"

using namespace std;
int main()
{
	account a;
	
	return 0;
}

account.h

#include <iostream>
#include "Lentext.h"
#include "Deltext.h"

#include <string>
using namespace std;
class account
{
private: 
	char account_Number[11];
	char name[1000];
	char address[1000];
	char city[16];
	char state[3];
	char zip_Code[10];
	char account_Balance[1000];
public:

	//default account constructor
	account();

	//set each field to a empty string
	void Clear();

	//sets the private variables above
	void set_account_number(string account_Number_Value);
	void set_title(string first_Last);
	void set_address(string location);
	void set_city(string county);
	void set_state(string loc);
	void set_zip_code(string zip);
	void set_account_balance(string user_balance);

	//methods for Lentext
	int Pack(LengthTextBuffer&) const;
	int UnPack(LengthTextBuffer&);

	//methods for Deltext
	int Pack(DelimTextBuffer&) const;
	int UnPack(DelimTextBuffer&);

	//print data
	void Print(ostream &);
};

account.ccp

#include "Account.h"
#include <iostream>
#include <iomanip>
using namespace std;

void account::set_account_number(string account_Number_Value)
{
	char* a=new char[account_Number_Value.size()+1];
	a[account_Number_Value.size()]=0;
	memcpy(account_Number, account_Number_Value.c_str(),account_Number_Value.size());
	//account_Number=account_Number_Value;
}

void account::set_title(string first_Last)
{
	char* a=new char[first_Last.size()+1];
	a[first_Last.size()]=0;
	memcpy(name, first_Last.c_str(),first_Last.size());
	//name=first_Last;
}

void account::set_address(string location)
{
	char* a=new char[location.size()+1];
	a[location.size()]=0;
	memcpy(address, location.c_str(),location.size());
	//address=location;
}

void account::set_city(string county)
{
	char* a=new char[county.size()+1];
	a[county.size()]=0;
	memcpy(city, county.c_str(),county.size());
	//city=county;
}

void account::set_state(string loc)
{
	char* a=new char[loc.size()+1];
	a[loc.size()]=0;
	memcpy(state, loc.c_str(),loc.size());
	//state=loc;
}

void account::set_zip_code(string zip)
{
	char* a=new char[zip.size()+1];
	a[zip.size()]=0;
	memcpy(zip_Code, zip.c_str(),zip.size());
	//zip_Code=zip;
}

void account::set_account_balance(string user_balance)
{
	char* a=new char[user_balance.size()+1];
	a[user_balance.size()]=0;
	memcpy(account_Balance, user_balance.c_str(),user_balance.size());
	//account_Balance=user_balance;
}

account::account()
{
	Clear();
}

void account::Clear()
{
	account_Number[0]=0;
	name[0]=0;
	address[0]=0;
	city[0]=0;
	state[0]=0;
	zip_Code[10]=0;
	account_Balance[1000]=0;
}

//pack the fields into a FixedTextBuffer
//return true if all succeed
int account::Pack(LengthTextBuffer & Buffer) const
{
	int result;
	Buffer.Clear();
	result=Buffer.Pack(account_Number);
	result=result&&Buffer.Pack(name);
	result=result&&Buffer.Pack(address);
	result=result&&Buffer.Pack(city);
	result=result&&Buffer.Pack(state); …
lotrsimp12345 37 Posting Pro in Training

I was wondering if any one had any suggestions for areas to research which tie with Artificial Intelligence. My interest is AI but since I haven't taken a class in AI. I can't do a project in that.

lotrsimp12345 37 Posting Pro in Training

thanks i figured it out. I was being dumb forgetting about the links.

lotrsimp12345 37 Posting Pro in Training

please help don't understand what's wrong.

lotrsimp12345 37 Posting Pro in Training

the delete must be by copying the data and then deleting if their are 2 nodes from that one root.


CODE IS AT VERY END FOR THAT. CALLED REMOVE.


Thanks.

main

#include <iostream>
#include "my_bst.h"
using namespace std;

int main()
{
	my_bst<int,int> ab;
	ab.insert(4,1);
	ab.insert(2,2);
	ab.insert(6,3);
	ab.insert(1,4);
	ab.insert(3,5);
	ab.insert(5,6);
	ab.insert(7,7);
	cout<<"preorder print:\n";
	ab.preorder_print();
	cout<<endl;
	cout<<"inorder print:\n";
	ab.inorder_print();
	cout<<endl;
	cout<<"postorder print:\n";
	ab.postorder_print();
	cout<<endl;
	cout<<"key doesn't exist in tree?\n";
	ab.search(200);
	cout<<"key was found in tree?\n";
	ab.search(2);
	ab.remove(2);
	
	return 0;
}

BST node

#ifndef MY_BST_NODE_H
#define MY_BST_NODE_H

#include <iostream>

using namespace std;

template<class KT,class DT>
class my_bst_node
{
public:
	my_bst_node();
	my_bst_node(KT tag, DT info, my_bst_node* l=0, my_bst_node* r=0);

	KT key;
	DT data;
	my_bst_node* left;
	my_bst_node* right;
};

template<class KT, class DT>
my_bst_node<KT,DT>::my_bst_node()
{
		left=right=0;
}

template<class KT, class DT>
my_bst_node<KT,DT>::my_bst_node(KT tag, DT info, my_bst_node* l, my_bst_node* r)
{
		key=tag;
		data=info;
		left=l; 
		right=r;
}

#endif

my bst

#ifndef MY_BST_H
#define MY_BST_H
#include <iostream>
#include "my_bst_node.h"

using  namespace std;

template<class KT,class DT>
class my_bst
{
public:
	//default constructor
	my_bst();

	//inserts a new node into binary tree
	void insert(KT searchkey, const DT &newDataItem);

	//search for the key and if found return true
	void search(KT searchkey);

	//prints out tree based on visiting the root node, then the left subtree and last the right subtree
	void preorder_print();

	//prints out tree based on visiting the left subtree, then the root node, and last the right subtree
	void inorder_print();

	//prints out tree based on visiting the left subtree, then the …
lotrsimp12345 37 Posting Pro in Training

1>c:\users...\documents\visual studio 2008\projects\generic bst container\generic bst container\my_bst.h(80) : warning C4717: 'my_bst<int,int>::insert_sub' : recursive on all control paths, function will cause runtime stack overflow

TEST.CPP

#include <iostream>
#include "my_bst.h"
using namespace std;

int main()
{
    my_bst<int,int> ab;
    ab.insert(5,10);
    return 0;
}

MY_BST_NODE.H

#ifndef MY_BST_NODE_H
#define MY_BST_NODE_H

#include <iostream>

using namespace std;

template<class KT,class DT>
class my_bst_node
{
public:
    inline my_bst_node()
    {
        left=right=0;
    }
    inline my_bst_node(KT tag,DT info, my_bst_node * l=0, my_bst_node * r=0)
    {
        key=tag;
        data=info;
        left=l; 
        right=r;
    }

    KT key;
    DT data;
    my_bst_node * left;
    my_bst_node * right;
};

#endif

MY_BST.H

#ifndef MY_BST_H
#define MY_BST_H
#include <iostream>
#include "my_bst_node.h"

using  namespace std;

template<class KT,class DT>
class my_bst
{
public:
    //default constructor
    my_bst();

    //inserts a new node into binary tree
    void insert(KT searchkey, const DT &newDataItem);

    //
    bool search(KT searchkey);

    //delete node based on which key you want to delete
    void delet(KT searchkey);

    //
    DT preorder_display(KT searchkey);

    //
    DT inorder_display(KT searchkey);

    //
    DT postorder_display(KT searchkey);

    //returns height of BST
    int height() const;

    //
    bool balanced() const;

    //
    void show_bst_structure() const;

private:
    my_bst_node<KT,DT>* root;

    void insert_sub(my_bst_node<KT,DT>*& root, KT searchkey, const DT & newDataItem);

    int getHeightSub(my_bst_node<DT,KT> * p);
};

template <class KT, class DT>
my_bst<KT,DT>::my_bst(void)
{
    root=0;
}

template <class KT, class DT>
void my_bst<KT,DT>::insert(KT searchkey, const DT &newDataItem)
{
    insert_sub(root, searchkey, newDataItem);
}

template <class KT, class DT>
void my_bst<KT,DT>::insert_sub(my_bst_node<KT,DT>*& root, KT searchkey, const DT &newDataItem)
{
   //if empty tree
   if(root=NULL)
   {
       root=new my_bst_node<KT,DT>(searchkey, newDataItem);
   }
   //key less than root nodes 
   else if(searchkey<root->key)
   {
       insert_sub(root->left, searchkey, newDataItem); …
lotrsimp12345 37 Posting Pro in Training

thanks! It works.

lotrsimp12345 37 Posting Pro in Training

so i still need to #include both the .h in my main, just move my code cpp code into my .h file. Do i still need a namespace? Not necessary correct? still need those #ifndef? Thanks

lotrsimp12345 37 Posting Pro in Training

thanks will look into it.

lotrsimp12345 37 Posting Pro in Training

Error 1 error LNK2019: unresolved external symbol "public: __thiscall vector::my_vector<int>::~my_vector<int>(void)" (??1?$my_vector@H@vector@@QAE@XZ) referenced in function _main test.obj

Error 2 error LNK2019: unresolved external symbol "public: __thiscall vector::my_vector<int>::my_vector<int>(void)" (??0?$my_vector@H@vector@@QAE@XZ) referenced in function _main test.obj

Error 3 fatal error LNK1120: 2 unresolved externals C:\Users...\Documents\Visual Studio 2008\Projects\Iterator and Generic Vector Container\Debug\Iterator and Generic Vector Container.exe

if i have the code below and close my_vector<int> v1 then their are no errors which leads me to believe the errors are in my_vector class. and it probably deals with the begin() and end() in my_vector.cpp class not having a template type. That's what i think. Any help appreciated thanks again.

test program(test.cpp)

#include "my_vector.h"
#include "my_vector_iterator.h"

using namespace vector;

int main()
{
    my_vector<int> v1;
    vector_iterator<int> itr;
    return 0;
}

my_vector.h

//my_vector.h

#ifndef MY_VECTOR_H
#define MY_VECTOR_H

#include "my_vector_iterator.h"
#include "my_vector_iterator.cpp"

namespace vector
{
    template<class DT>
    class my_vector
    {
    public:
        //destructor
        ~my_vector();

        //copy constructor
        my_vector(const my_vector<DT>& b);

        //constructor that create an empty vector
        my_vector();

        /*constructor that create an vector with capacity specified 
        as a parameter but doesn't assign values to each element
        in the vector*/
        my_vector(unsigned int intial_Size);

        /*constructor that create a vector with capacity specified 
        as a parameter and assign all the elements the value 
        specified*/
        my_vector(unsigned int intial_Size, DT assign);

        //overloaded assignement operator
        my_vector& operator=(const my_vector<DT>& a);

        //returns total number of elements in an array
        int capacity();

        //returns number of elements in array that are filled
        int size();

        //adds an value at next position in vector
        void push_back(DT user_number);

        //prints out the vector that …
lotrsimp12345 37 Posting Pro in Training

problem was circular inclusion.

lotrsimp12345 37 Posting Pro in Training

Please help!!!

lotrsimp12345 37 Posting Pro in Training

Here's updated code

ERRORS are missing type specifier at the line above and same with end. All errors are on same line.


MY_VECTOR.h

//my_vector.h


#ifndef MY_VECTOR_H
#define MY_VECTOR_H
#include "my_vector_iterator.h"

namespace vector
{
	template<class T>
	class my_vector
	{
	public:
		//destructor
		~my_vector();

		//copy constructor
		my_vector(const my_vector<T>& b);

		//constructor that create an empty vector
		my_vector();

		/*constructor that create an vector with capacity specified 
		as a parameter but doesn't assign values to each element
		in the vector*/
		my_vector(unsigned int intial_Size);

		/*constructor that create a vector with capacity specified 
		as a parameter and assign all the elements the value 
		specified*/
		my_vector(unsigned int intial_Size, T assign);
	
		//overloaded assignement operator
		my_vector& operator=(const my_vector<T>& a);

		//returns total number of elements in an array
		int capacity();
	
		//returns number of elements in array that are filled
		int size();

		//adds an value at next position in vector
		void push_back(T user_number);

		//prints out the vector that contains the numbers recursively
		void show_vector(unsigned int siz);

		//deletes the number from last element that stores a number
		void pop_back();

		//return value at the index specified by user
		T at(size_t arrayindex);
	
		//return value at index specified by user
		T operator[](size_t array_index);

		//return a iterator to first value in container
		my_vector_iterator<T> begin();

		//return a iterator to value after one in container
		my_vector_iterator<T> end();

	private:

		//array to store numbers
		T* numbers;

		//total amount of elements that can be stored in array
		int capacit;

		//number of elements that are filled
		int siz;
	};
}
#endif

MY_VECTOR.cpp

//Implementation of functions in my_vector.h
#include …
lotrsimp12345 37 Posting Pro in Training

now i have it down to 6 errors!!!!
it doesn't like this code :(. please help

my_vector_iterator<T> begin();

lotrsimp12345 37 Posting Pro in Training

I have a dynamic array and i am trying to create a iterator class to support the list. I am adding begin and end. As well as a new class.


error C2146: syntax error : missing ';' before identifier 'begin'

Error 7 error C2146: syntax error : missing ';' before identifier 'end'

error C2244: 'vector::my_vector_iterator<DT>::my_vector_iterator' : unable to match function definition to an existing declaration

error C2653: 'my_vector_iterator' : is not a class or namespace name

error C2904: 'my_vector_iterator' : name already used for a template in the current scope

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

MAIN

int main()
{
	return 0;
}

MY_VECTOR.h

//my_vector.h
#include "my_vector_iterator.h"
#include "my_vector_iterator.cpp"
#ifndef MY_VECTOR_H
#define MY_VECTOR_H

namespace vector
{
	template<class T>
	class my_vector
	{
	public:
		//destructor
		~my_vector();

		//copy constructor
		my_vector(const my_vector<T>& b);

		//constructor that create an empty vector
		my_vector();

		/*constructor that create an vector with capacity specified 
		as a parameter but doesn't assign values to each element
		in the vector*/
		my_vector(unsigned int intial_Size);

		/*constructor that create a vector with capacity specified 
		as a parameter and assign all the elements the value 
		specified*/
		my_vector(unsigned int intial_Size, T assign);
	
		//overloaded assignement operator
		my_vector& operator=(const my_vector<T>& a);

		//returns total number of elements in an array
		int capacity();
	
		//returns number of elements in array that are filled
		int size();

		//adds an value at next position in vector
		void push_back(T user_number);

		//prints out the vector that contains the numbers …
lotrsimp12345 37 Posting Pro in Training

that's what i thought. Its crazy i don't think it is possible without helper functions and you probably want to keep head private.

lotrsimp12345 37 Posting Pro in Training

This is what he wants me to do.

Consider a singly-linked list sequence container of data items of type DT (named template class my_list). The
operations should include constructors, copy constructor, destructor, overloaded assignment operator (=), size,
push_back, pop_back, push_front, pop_front, (recursive) reverse and (recursive) show_sllist.

lotrsimp12345 37 Posting Pro in Training

my teacher doesn't want us to do that. He only wants one function to do all of it. No helper functions.

lotrsimp12345 37 Posting Pro in Training

how do i do that? and their is still something wrong with the code. :(.

lotrsimp12345 37 Posting Pro in Training
template<class T>
	void my_list<T>::show_sllist(my_node<T>* p)
	{
		
		if(p!=0)
		{
			cout<<p->data;
			show_sllist(p->next);
		}
		
		/*my_node<T>* temp=head;
		if(head==0&&tail==0)
		{
			cout<<"nothing to show\n";
		}
		else
		{
			while(temp->next!=0)
			{
				cout<<temp->data<<"\n";
				temp=temp->next;		
			}
			cout<<temp->data<<endl;
		}*/
	}

head can't be accessed in main because it is a private variable :(.

main

#include <iostream>
using namespace std;

#include "my_list.h"
#include "my_list.cpp"
using list::my_list;

int main()
{
	//Test 1
	cout<<"TEST1\n";
	my_list<double> a;
	a.push_back(1.3);
	a.push_back(2.4);
	cout<<"Object1:\n";
	a.show_sllist(a.head);
	//my_list<double> b(a);
	//cout<<"Object2:\n";
	//b.show_sllist();
	//cout<<endl;
lotrsimp12345 37 Posting Pro in Training

Don't think you can pass any parameter unless you create a point in your main.

template<class T>
	void my_list<T>::show_sllist(my_node<T>* p)
	{
		if(p!=0)
		{
			cout<<p->data;
			show_sllist(p->next);
		}
         }

Would i have to create a pointer of type my_node in main to show the list.

#include <iostream>
using namespace std;

#include "my_list.h"
#include "my_list.cpp"
using list::my_list;

int main()
{
	//Test 1
	cout<<"TEST1\n";
	my_list<double> a;
	a.push_back(1.3);
	a.push_back(2.4);
	cout<<"Object1:\n";
	a.show_sllist();
	my_list<double> b(a);
	cout<<"Object2:\n";
	b.show_sllist();
	cout<<endl;

	//Test 2
	/*cout<<"TEST2\n";
	my_list<int> c;
	c.push_back(1);
	c.push_back(2);
	cout<<"Object1:\n";
	c.show_list();
	my_list<int> d(c);
	cout<<"Object2:\n";
	d.show_list();
	my_list <int>e;
	e=d;
	e.push_back(10);
	cout<<"Object3:\n";
	e.show_list();*/
	return 0;
}
lotrsimp12345 37 Posting Pro in Training

for recursion don't you need a base case and then all the other cases?

lotrsimp12345 37 Posting Pro in Training

almost working just prints out memory location and i believe that is because of the 0 i think it should be ==1.

lotrsimp12345 37 Posting Pro in Training

but it has to be recursive. nvm i see.

lotrsimp12345 37 Posting Pro in Training

problem is that it prints out backwards, can't figure out a way to flip it. prolbem is with numbers[siz-1] which begins at last index not first.

template<class T>
	T my_vector<T>::show_vector(unsigned int siz)
	{
		if(siz==1)
		{
			cout<<"enter size of array is 1\n";
			return numbers[0];
		}
		else
		{
			cout<<"enter this statement"<<endl;	
			cout<<numbers[siz-1]<<"\n";
			return show_vector(siz-1);
		}
	}
lotrsimp12345 37 Posting Pro in Training

no i thought you were refering to my int main(). My bad.

lotrsimp12345 37 Posting Pro in Training

thanks. I asked teacher he told me same thing.

lotrsimp12345 37 Posting Pro in Training

HERE IS MOST RECENT CODE. DOESN'T SEEM TO ENTER IF CONDITION IN MY MAIN.

MAIN

//CS 310
/*Create a text file and input in certain data into the text
file*/
//Program one

#include <iostream>
#include <fstream>
#include "Account.h"
using namespace std;
int main()
{
    account b;
    char name1[256];
    bool c=true;
    cout<<"enter file name to be opened\n";
    cin>>name1;
    ofstream infile;
    infile.open(name1);
    if(!infile)
    {
        cout<<"File could not open\n";
        exit(1);
    }
    else
    {   
        while(c==true)
        {
            cin>>b;
            if(b.get_account_number()==-1)
            {
                cout<<"enter this condition?\n";
                c=false;
            }
            else
            {
                infile<<b;
                c=true;
            }
        }
    }

    return 0;
}

INTERFACE

//class used to create an account

#include <string>
using namespace std;
class account
{
private: 
    int account_Number;
    string name;
    string address;
    string city;
    string state;
    int zip_Code;
    double account_Balance;
public:

    //default account constructor
    account(int=0,  string="", string="", string="", string="", int=0, double=0);

    //sets the private variables above
    void set_account_number(size_t account_Number_Value);
    void set_title(string first_Last);
    void set_address(string location);
    void set_city(string county);
    void set_state(string loc);
    void set_zip_code(int zip);
    void set_account_balance(double user_balance);

    //gets the members value
    int get_account_number();
    string get_title();
    string get_address();
    string get_city();
    string get_state();
    int get_zip_code();
    double get_account_balance();

};

//overloaded operator to allow an object to be read in
istream& operator>>(istream&in,account& c);

//overload operator to an object to be read to the file
ostream& operator<<(ostream& out, account& z);

IMPLEMENATATION

#include "Account.h"
#include <iostream>
#include <iomanip>
using namespace std;

account::account(int accountNumberValue,string nameValue,string addressValue, string cityValue, string stateValue,
                 int zipCodeValue,double AccountBalanceValue)
{
    set_account_number(accountNumberValue);
    set_title(nameValue);
    set_address(addressValue);
    set_city(cityValue);
    set_state(stateValue);
    set_zip_code(zipCodeValue);
    set_account_balance(AccountBalanceValue);
}

void account::set_account_number(size_t account_Number_Value)
{
    account_Number=account_Number_Value;
}

void account::set_title(string first_Last)
{ …
lotrsimp12345 37 Posting Pro in Training

nope problem still exists even if i change to b.get_account_number. :(.

lotrsimp12345 37 Posting Pro in Training

i am an idiot for typing in accont balance instead of number.

lotrsimp12345 37 Posting Pro in Training

the infinite loop problem still remains.

lotrsimp12345 37 Posting Pro in Training
//CS 310
/*Create a text file and input in certain data into the text
file*/
//Program one

#include <iostream>
#include <fstream>
#include "Account.h"
using namespace std;
int main()
{
    account b;
    char name1[256];
    cout<<"enter file name to be opened\n";
    cin>>name1;
    ofstream infile;
    infile.open(name1);
    if(!infile)
    {
        cout<<"File could not open\n";
        exit(1);
    }
    else
    {   
        while(cin>>b)
        {
            cout<<"account number is"<<b.get_account_number();
            if(b.get_account_balance()==-1)
            {
                cout<<"enter this condition?\n";
                break;
            }
            else
            {
                infile<<b;
            }
        }
    }

    return 0;
}
lotrsimp12345 37 Posting Pro in Training

this causes the same problem as before. It doesn't show hit any key to enter.

lotrsimp12345 37 Posting Pro in Training

k thanks i will try that.

lotrsimp12345 37 Posting Pro in Training

the program is supposed to open a file and write from cin the account object. It is supposed to read an account object each time until the account number is -1.

lotrsimp12345 37 Posting Pro in Training

i believe the problem is it must read all 7 data members.

lotrsimp12345 37 Posting Pro in Training

the program is supposed to write the account object to the file until the account object data member accountNumber has a value of -1.

lotrsimp12345 37 Posting Pro in Training

basically while b.get_account_number() value is changing. Atleast it seems to be. So to fix this would i need to create another constructor which takes in a value of accountNumber?