So I have a program to write where it reads a file that contains a matrix so to say, so containing n lines of text. For example, the file would contain:
7 [ number of columns]
5 [ number of rows]...
Type: Posts; User: stefanyco
So I have a program to write where it reads a file that contains a matrix so to say, so containing n lines of text. For example, the file would contain:
7 [ number of columns]
5 [ number of rows]...
Well what would be causing me to get a bad_alloc error? And/or CPU time limit exceeded?
I add print statements after everything and the error seems to be only with adding ints to the vector with...
The data file contains a series of random numbers using a different program that writes to a data.txt file.
I use srand(time(0)); cout << rand();
So the file looks like this:
1485738376...
I'll reply to myself. I ALSO tried:
do {
cin >> number;
list.push_back(number);
} while (number);
Hello! so, I'm implementing quicksort and selection sort using vectors.
I have the following code. To run I use redirection. i.e. ./program.out <datafile
int main()
{
int number;
...
So I'm relatively new to coding, and I might sound like a noob right now. :( I'd like for my laptop to have a code-friendly environment. I currently use Secure Shell client to create and compile...
If only. Professor requires it compile on this one for a grade. D:
I'll show him my problematic code, see what he says. hahaha
Yea, I've posted in 3 different forums and haven't been able to get it to compile. I know my implementation logic stuff is correct, because when I rewrote it without the mess it compiled fine.
g++...
@whiteflags Yes. I remember posting this code in frustration, I've fixed the type long ago when I had a brief moment of clarity. Haha
So, It still doesnt compile for me. Maybe my compiler doesn't...
So my solution to rid my code of friend-related errors was to implement the function in the class itself. My updated class is as follows:
template<class object>
class Tree
{
private:
...
I will try in the morning. Thanks!
Yes that is what I currently have.
template<class object>
void buildTree(TreeNode<object> *&tree);
template<class object>
class Tree
{
private:
I added the declaration before the class Tree.
The function is implemented as well.
I am getting error: friend declaration âvoid buildTree(TreeNode<object>*&)â declares a non-template function...
I have the following classes to implement building an expression tree. I have a function that I am having trouble placing: the buildTree function in class Tree. I am getting an undefined reference...
Oh no no, I understand that. I knew that I was just frustrated when I posted this and posted prematurely. :( I'm getting different errors now such as 'Stack is not a template' or 'template argument...
Better than no template, in this context.
And yes, got that.
Is using a template better? I keep getting errors such as "Stack is not a template" or "TreeNode<char>* TreeNode<char>::left is private within this context"
So i'm trying to convert a postfix expression to an expression tree and print it. I have the following classes. In the main, I have never really understood how to properly declare stuff. Im getting...
So let's say we're using a stack that fluctuates, as in infix to postfix expression conversions. At any given moment the stack may be empty, and if so it would abort because of the underthrow? What...
My professor uses
throw underflow;
in code, but I do not know what that does or under what library it is in.
void Stack<object>::pop()
{
if (isEmpty())
throw underflow;
Ah, I'll use a debugger. I somehow only thought debuggers were for assembly code. Haha.
And i have implemented a normal basic stack this way successfully before, that's why i suspected its the...
I agree, but pulling this out of main got it working somehow. And i am not confident with std::stack and how to implement using that so for now i just need to figure out why * after ) causes seg...
I am implementing a stack class to convert infix expressions to postfix expressions.
Program runs when I enter : (A*(B+C))
for example and gives me the correct ABC+*
But when I randomly entered...
Of course, the completed code has all that good checking stuff. Thank you!
Thank you all :)
I didn't need to output the string with whitespace, that was just for me to check. I also re-read a chapter on pointers and such and figured it out. Sorry!
Ushakal is correct, by...