User Profile

Collapse

Profile Sidebar

Collapse
KiddoGuy
KiddoGuy
Last Activity: Feb 12 '09, 01:35 AM
Joined: Nov 17 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • KiddoGuy
    replied to Problem appending character to c++ string
    in C
    Ooooooooooooooo ooooooops... Very amateur mistake. Fix'd
    See more | Go to post

    Leave a comment:


  • KiddoGuy
    started a topic Problem appending character to c++ string
    in C

    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
    ...
    See more | Go to post

  • KiddoGuy
    replied to Private Inner Classes
    in C
    Thank you, Jos. You've helped me many times.

    Hopefully my last problem before getting this to compile is this:
    Code:
    LinkedList<E>::Node<E> curNode;
    which gives "error: expected primary-expression before ‘>’ token".

    Since LinkedList is the enclosing class, this way of defining a Node called curNode makes sense to me but it is apparently wrong?

    ...
    See more | Go to post

    Leave a comment:


  • KiddoGuy
    started a topic Private Inner Classes
    in C

    Private Inner Classes

    I'm trying to implement a linked list in C++ but I'm having a problem with an inner class.
    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
    };
    I'm pretty sure...
    See more | Go to post
    Last edited by KiddoGuy; Dec 14 '08, 06:38 AM. Reason: formatting

  • KiddoGuy
    replied to C++ Template syntax question
    in C
    Ok, thanks. So if i am including the header I am extending and publicly extend that class by doing something like
    Code:
    template class<T>
    class LinkedList: public List
    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.

    The problem so far...
    See more | Go to post

    Leave a comment:


  • KiddoGuy
    replied to C++ Template syntax question
    in C
    Shouldn't I need class names somewhere in there?
    See more | Go to post

    Leave a comment:


  • KiddoGuy
    started a topic C++ Template syntax question
    in C

    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?
    See more | Go to post

  • KiddoGuy
    replied to Adding an icon to a JPanel
    in Java
    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.
    See more | Go to post

    Leave a comment:


  • KiddoGuy
    replied to Adding an icon to a JPanel
    in Java
    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.
    See more | Go to post

    Leave a comment:


  • KiddoGuy
    replied to Adding an icon to a JPanel
    in Java
    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.
    See more | Go to post

    Leave a comment:


  • KiddoGuy
    started a topic Adding an icon to a JPanel
    in Java

    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);
    ...
    See more | Go to post

  • KiddoGuy
    replied to Swing draw points
    in Java
    Actually, now my problem is when I'm trying to draw on a Panel. When I call getGraphics() it returns null...
    See more | Go to post

    Leave a comment:


  • KiddoGuy
    replied to Swing draw points
    in Java
    Ok, thanks. Can you give me a sample usage? Or is something like this correct?
    Code:
    java.awt.Panel panel = new java.awt.Panel();
    panel.getGraphics().drawRect(1,2,3,4);
    Would something like that work?
    See more | Go to post

    Leave a comment:


  • KiddoGuy
    started a topic Swing draw points
    in Java

    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?
    See more | Go to post

  • KiddoGuy
    replied to Segfault when calling fgetpos
    in C
    Thanks very much. I malloc'd it and it now works. Is there a standard size to allocate?
    See more | Go to post

    Leave a comment:


  • KiddoGuy
    started a topic Segfault when calling fgetpos
    in C

    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,...
    See more | Go to post

  • KiddoGuy
    started a topic Clearing a char pointer
    in C

    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 */
    		}
    	}
    ...
    See more | Go to post
No activity results to display
Show More
Working...