0
(node.h)
This is the code and it gives me these errors >>which confused me alot >>what are these errors ?!!
and what is the problem ?!!
Error   3   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   12 graph.h
Error   4   error C2660: 'graph::create' : function does not take 2 arguments   29       main.cpp
Error   8   error C2511: 'void graph::create(node *[],FILE *)' : overloaded member function not found in 'graph 17 graph.cpp
Error   2   error C2146: syntax error : missing ';' before identifier 'obj' 12           graph.h
Error   1   error C2061: syntax error : identifier 'node'       10        graph.h


plz help me :(

#pragma once
#include<iostream>

#define size 5
#define size_child 4
#define infinity 10000
using namespace std ;
class node
{
protected:
    int index;
    int weight_edge[size_child];
    int child[size_child];
    int count;
    bool visited;
    int parent;
    int distance;

public:
    node(void);
    node(int);
    ~node(void);
     friend class graph;
};

(node.cpp)
#include "node.h"
#include<iostream>
using namespace std ;
node::node(void)
{
    index=0;
    weight_edge[size_child]=0;
    child[size_child]=0;
    count=0;
    visited=false;
    parent=-1;
    distance=infinity;

}


node::~node(void)
{
}

(graph.h)
#pragma once
#include<iostream>
using namespace std ;

class graph
{
public:
    graph(void);
    ~graph(void);
    void create(node*[],FILE* );
    void print_menu();
    node obj;
    int n;
};

(graph.cpp)
#include "graph.h"
#include "node.h"
#include<iostream>
using namespace std ;

graph::graph(void)
{
    n=0;
}


graph::~graph(void)
{
}

void graph::create(node*g[size], FILE*fp)
{
        int j,i;
            fscanf(fp,"%d",&n);
            for (i = 0; i < n; i++)
            {
                g[i]=new node;
            }
            for( j=0;j<n;j++)
            {

            fscanf(fp,"%d",&(obj.index));
            fscanf(fp,"%s",&(g[obj.index]->count));
            for ( j = 0; j<g[obj.index]->count; j++)
                {
           fscanf(fp,"%s",&(g[obj.index]->child[j]));
                }
            for (i = 0; i < g[obj.index]->count; i++)
            {
            fscanf(fp,"%s",&(g[obj.index]->weight_edge[i]));
            }
            }
}
void graph:: print_menu()
    {
      cout <<"***********MAIN MENU************\n";
      cout <<"*\t1-load new file \n";
      cout <<"*\t2-Find the starting task \n";
      cout <<"*\t3-find the ending task \n";
      cout <<"*\t4-find and print the longest path \n";
      cout <<"*\t5-exit \n";
      cout <<"*********************************\n";
    }

    (main.cpp
    #include<cstdio>
#include<iostream>
#include "graph.h"
#include "node.h"
#include<stdlib.h>
using namespace std ;
int main (){
    char ch;
    node*g[size];
    FILE *p;
    graph obj2;
    obj2.print_menu();
    while (true)
    {
        cout<<"**enter which process U want**"<<endl<<endl<<endl;
        cin>>ch;
    switch (ch)
    {
    case ('1'):
        char name[20];
        cout<<"plz enter the name of the file U want to OPEN \n";
        cin>>name;
        p=fopen(name,"a+");
        if((p=fopen(name,"a+"))==NULL)
        {
            cout<<"FILE NOT FOUND\n";
        }
        else
        obj2.create(g,p);
        fclose(p);
    break;
    case ('4'):
        exit(0);
    break; 

default:
    cout<<"NOTHING"<<endl;
        break;

    }
    }




getchar();
getchar();
return 0; 
}
2
Contributors
1
Reply
7
Views
2 Years
Discussion Span
Last Post by tinstaafl
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.