User Profile
Collapse
-
Ooooooooooooooo ooooooops... Very amateur mistake. Fix'd -
Problem appending character to c++ string
I am trying to build a string character by character. However, when I use the overloaded += or string.append() method, the character replaces the one before it rather than appending to it so I am constantly left with a string of length 1. Here's a sample of what I'm trying to do.
...Code:char cur; while(!fin.eof()) { //(fin is an ofstream) string currstr = ""; //This is part of what's giving me a problem -
Thank you, Jos. You've helped me many times.
Hopefully my last problem before getting this to compile is this:
which gives "error: expected primary-expression before ‘>’ token".Code:LinkedList<E>::Node<E> curNode;
Since LinkedList is the enclosing class, this way of defining a Node called curNode makes sense to me but it is apparently wrong?
...Leave a comment:
-
Private Inner Classes
I'm trying to implement a linked list in C++ but I'm having a problem with an inner class.
I'm pretty sure...Code:template<class E> class LinkedList: public List { private: Node<E> head; class Node<E> { private: E data; Node* next; Node* prev; friend class List; }; public: //constructors and stuff here }; -
Ok, thanks. So if i am including the header I am extending and publicly extend that class by doing something like
should that be fine? Do I need to declare a generic type on List? I'm sorry... I'm fluent in Java and C but still learning nuances of C++ and writing my first program using templates... kind of jumped in the deep end.Code:template class<T> class LinkedList: public List
The problem so far...Leave a comment:
-
-
C++ Template syntax question
Hello, I have an "abstract" template header file that I am extending with another header file. I want to implement the methods from the abstract class in the extending class header file. One is called List and the other is called LinkedList, which is the implementation of List. What should the method headers look like for, say, an add method that takes a generic parameter? -
Ooh yes, I can definitely see that rectangle. I think the problem is with using the JLabel, but I can't think of what it could be.Leave a comment:
-
Yes, the action listener is working properly. I had it modify text in a different window and that worked. I added text to the label and it did not display in the jpanel.Leave a comment:
-
It did indeed print the path, so it is loading properly. I set the layout using NetBeans, so the code is not the prettiest and I doubt you want to read through it. I have a main JFrame which contains, among other things, a tabbed panel which houses 2 panels. These do show up properly, but I'm having difficulties adding anything to these two panels. This is my first time creating a GUI so I do have much to learn.Leave a comment:
-
Adding an icon to a JPanel
Hello, I'm trying to add an icon to a JPanel in the event where a button is pressed. I have the following code:
...Code:private void button1ActionPerformed(java.awt.event.ActionEvent evt) { javax.swing.ImageIcon icon = new javax.swing.ImageIcon("/home/bbraun/NetBeansProjects/RPGI/sample2.jpg"); javax.swing.JLabel label = new javax.swing.JLabel(); label.setIcon(icon); -
Actually, now my problem is when I'm trying to draw on a Panel. When I call getGraphics() it returns null...Leave a comment:
-
Ok, thanks. Can you give me a sample usage? Or is something like this correct?
Would something like that work?Code:java.awt.Panel panel = new java.awt.Panel(); panel.getGraphics().drawRect(1,2,3,4);
Leave a comment:
-
Swing draw points
I want to loop through an array of numbers and use those to plot points. What method should I be thinking of? I know there's one that takes an X and Y coordinate and draws points. Is there one that draws bars, too? -
Thanks very much. I malloc'd it and it now works. Is there a standard size to allocate?Leave a comment:
-
Segfault when calling fgetpos
Hello, I am trying to save my position in a file to resume after running some checks that will position the file pointer at EOF.
fpos_t *floc; /* location in file to where i want to return */
/* in between here i search for a string */
fgetpos(fp, floc); /* where fp is of type FILE* */
I am sure it is segfaulting when calling fgetpos... What am I doing wrong? If the string is not found the function exits,... -
Clearing a char pointer
I have the following code
...Code:int parseFile(FILE* fp, char s[]) { char *buffer; int c, i; i = 0; buffer = (char*)malloc(MAX_ARRAY+1); while ((c = getc(fp)) != EOF) { while (!isspace(c)) { *(buffer+i) = c; i++; c = getc(fp); } i = 0; if (strcmp(buffer, s) == 0) { return 0; /* found */ } }
No activity results to display
Show More
Leave a comment: