Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

It doesn't compile wtf did I do wrong?

Name: Anonymous 2006-03-27 10:54

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

int main()
{
    int node;
    cout << "Number of nodes: ";
    cin  >> node;
    cNode *circle = new cNode[node];
    int nodeVal[node];                      
    int nodes = node;
    while (node >= 0){
         cout << "\nInput value for node " <<(nodes - node + 1) << endl;
         cin  >> nodeVal[(nodes - node)];
         node--;
    }
    node = nodes;
    while (node >= 0){
         int curNode = (nodes - node);
         *circle[curNode].setValue(nodeVal[curNode]);
         node--;
    }
}

29 R:\Ants.cpp invalid type argument of `unary *'

Name: Anonymous 2006-03-27 11:50 (sage)

*circle[curNode].setValue(nodeVal[curNode]);

this doesn't make sense because:
1. arrays are the same as pointers in C, so there's nothing to dereference
2. that actually would be dereferencing the return value of setValue and doing nothing with it, anyway

Name: Anonymous 2006-03-27 23:10

>> 2
1. What the hell does that mean?
2. setValue doesn't return anything. It changes a class value.

More importantly, how do I fix it? And what is a `unary *'?

Name: Anonymous 2006-03-28 2:05

>>3
Remove the * from the start of the line you bloody tard.

Name: Anonymous 2006-03-28 3:08 (sage)

This is /prog not /homework

Name: Anonymous 2006-03-29 2:55

>>5 where is /homework (ie, where **can** I ask my tard questions at)?

Name: Anonymous 2006-03-29 2:56

>>6
Here, silly

Name: Anonymous 2006-03-29 5:39 (sage)

>>6
You have to create a buffer overflow first and change /prog to /homework

Name: Anonymous 2006-04-01 1:18 (sage)

Why do you count node down from nodes to 0, and then index everything with curNode? You could have just started node from 0 and counted up to nodes, and just used that as the index.

Also, for loops are probably better for this kind of thing.

btw, unary * refers to the * in *circle[curNode].setValue(...). Just take out that *, as mentioned in >>2

Next time you should probably figure these things out for yourself. Your mistake seems to show that you don't have a clear understanding of pointers and arrays in C++.

http://www.parashift.com/c++-faq-lite/index.html

Name: Anonymous 2006-04-07 13:01

>>3
>>What the hell does that mean?
This means you suck at C++.

Name: Anonymous 2009-08-16 23:02

Lain.

Name: Anonymous 2011-02-04 17:05

Name: : 2011-10-18 15:26

Test post please ignore

Don't change these.
Name: Email:
Entire Thread Thread List