User Profile
Collapse
-
i figured it out, i didn't need nodetype *c because it would be adding node. -
Linked lists and inserting nodes (c++)
the program runs without errors, but when i try to use the changenode function, if i put anything above 2 it doesn't change the correct node. here is the source code.
...Code:#include <iostream.h> #include <fstream.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> typedef struct node{ int data1; -
c++ calling link lists in main..serious help :/
i understand the concept of linked lists and how they work, but i cannot seem to grasp how to convert random numbers in the main to. if anyone can help fix my code up that would be really helpful.
...Code:#include <iostream.h> #include <fstream.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> typedef struct linknode{ -
linked list...no error, but not the right information
here is the entire source code. there are no errors, but what it is outputting is not what i want.
...Code:#include <iostream.h> #include <fstream.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> typedef struct linknode{ int data1; char data2; linknode *p; } nodetype; int -
-
C++ Polymorphism conversion error
The error I am getting is:
ERROR E2034 Cannot Convert 'Data 3 *' to 'Gg *' in function main()
This is my source code, well the stuff that matters I believe. The code is about 500 lines, and I didn't want to flood it, so yeah here you go.
...Code:class Data3: public Data2a, public Data2b{ protected: int *p2; int *p3; int ct1; int forever1; public: Data3(); ~Data3(); -
-
if i do that, then class 3 wouldn't be recognized in the Host3 class.Leave a comment:
-
C++ Class Function/Method Friends?
i'm trying to use the method friends in this class 3...here is the error im getting.
Error 2316 112: 'Host3::seeData (Class3)' is not a member of 'Host3'
...Code:class Host3; class Class3: public Class2{ protected: int *p5; public: Class3(); ~Class3(); void inputData(); void showData(); friend int Host3::seeData(Class3 ); -----------$$$$$$$$$$$$-------LINE 112~~~~~ -
-
correct, when I do that it crashes after printing the 100 random numbers.Leave a comment:
-
if i'm understanding you correctly, i would just change
toCode:Data1::Data1(){ p1 = new int[1300]; size1 = 1300; }
Code:Data1::Data1(){ p1 = new int[100]; size1 = 100; }Leave a comment:
-
Overloading classes problem...
I'm trying to run this program and it works, but I would like to clean it up and make it more acceptable. One of the problems I am having is that when the program runs when I put p1 to 100 to print the random numbers it will print them, but then the program crashes. When I put p1 = 1300, it runs because that is the number of actual integers in the file I'm reading from. Here is the source code.
...Code:class Data1{ protected: -
okay great. thanks for your help. if i'm trying to read multiple files from a text file, how would it look like. this is what i have so far.
...Code:typedef struct record1{ int n1; string name1; char c1; double d1; } set1; class Class1{ private: int ct; set1 *s1; public: void rarray(); void parray(); };Leave a comment:
-
...Code:class Class1{ private: int ct; int *p; int forever; public: void parray(); void rarray(); }; void Class1::rarray(){ ifstream in1("nums.dat"); ct=0; p=new int[1300]; forever=1; while(forever){ in1 >> *(p+ct); if(*(p+ct) == -1) break; ct++; } // WHILE LOOP } voidLeave a comment:
-
well that is the main() and all the codes really. all there really else is the cout << part. so do you think you can help me adjust these into a class?Leave a comment:
-
Reading integers from a file into classes.
I'm fairly new to classes and I know how to read integers from a file into the main, but I'm really getting confused on how to do it in classes.
for example...
...Code:ifstream in1("nums.dat"); int ct=0; int *p=new int[1300]; int forever=1; while(forever){ in1 >> *(p+ct); if(*(p+ct) == -1) break; ct++; -
How do you input size into a Class Function?
...Code:class Class1{ private: int size; int x1[40]; public: void sayit(int size); void sayit(int size); void doit(); void writeit(); }; // cs1 void Class1::sayit(int size){ cout <<"\n\n\t Random Numbers\n\n"; }//sayit void Class1::sayit(int size){ cout <<"\n\n\t Random Numbers\n\n"; }//sayit -
i just commented out the entire block of string code. when i comment out the block it compiles fine, but it does not sort.Leave a comment:
-
How to sort structure arrays
...Code:typedef struct record1{ int n1; string name1; char c1; double d1; } set1; int swap2(int &n1, int &n2){ int temp; temp=n1; n1=n2; n2=temp; return 1; } // SWAP 2 NUM int swap2(char &n1, char &n2){ char temp; temp = n1; n1 = n2; n1 = temp; return 1; } // SWAP 2 CHAR int
No activity results to display
Show More
Leave a comment: