Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 28.12.2008, 22:26   #21
xsix
Пользователь
 
Аватар для xsix
 
Регистрация: 27.12.2008
Сообщений: 20
По умолчанию

Исправил там, но говорит про эти ошибки:

Код:
1>matrix.cpp
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(57) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(107) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(112) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(136) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(145) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>vector.cpp
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : error C2006: '#include' : expected a filename, found 'identifier'
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : fatal error C1083: Cannot open include file: '': No such file or directory
1>main.cpp
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : error C2006: '#include' : expected a filename, found 'identifier'
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : fatal error C1083: Cannot open include file: '': No such file or directory
Что ему не нравиться с инклудами?

P.S. Это просто ужас...

Последний раз редактировалось xsix; 28.12.2008 в 22:35.
xsix вне форума Ответить с цитированием
Старый 28.12.2008, 23:03   #22
challengerr
Участник клуба
 
Аватар для challengerr
 
Регистрация: 30.07.2008
Сообщений: 1,601
По умолчанию

Код:
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(57) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(107) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(112) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(136) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\matrix.cpp(145) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Это уже мой косяк. По видимому он хочет void перед методами. Нужно явно указать voidы, где они нужны.
Например, вместо
Код:
template <class T>
matrix<T>::random()
нужно указать
Код:
template <class T>
void matrix<T>::random()
Так же в описании класса нужно указать
Код:
void random();
Аналогично с другими функциями. Смотри номера строк!


Код:
1>vector.cpp
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : error C2006: '#include' : expected a filename, found 'identifier'
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : fatal error C1083: Cannot open include file: '': No such file or directory
1>main.cpp
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : error C2006: '#include' : expected a filename, found 'identifier'
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : fatal error C1083: Cannot open include file: '': No such file or directory
Что там на 2 строке?
"SPACE.THE FINAL FRONTIER.This's a voyage of starship Enterprise. It's 5-year mission to explore strange new worlds,to seek out new life and civilizations,to boldly go where no man has gone before"

Последний раз редактировалось challengerr; 28.12.2008 в 23:06.
challengerr вне форума Ответить с цитированием
Старый 28.12.2008, 23:09   #23
xsix
Пользователь
 
Аватар для xsix
 
Регистрация: 27.12.2008
Сообщений: 20
По умолчанию

Там подключено вот что:
vector.cpp
Код:
#include "StdAfx.h"
#include "vector.h"
matrix.cpp
Код:
#include "StdAfx.h"
#include "matrix.h"
xsix вне форума Ответить с цитированием
Старый 28.12.2008, 23:13   #24
challengerr
Участник клуба
 
Аватар для challengerr
 
Регистрация: 30.07.2008
Сообщений: 1,601
По умолчанию

Описание класса должно быть таким. Перед самими методами тоже нужно поправить!! void указывается перед matrix<T> у метода
Код:
template <class T>
class matrix
{
	public:	
		matrix(int rows, int columns);
		~matrix();
		void manually_set();
		void print();
		void random();
		void set_from_array(T* k);		
		T get_by_index(int y,int x);
		void swap_values(int y1,int x1, int y2,int x2);
		void set_value(int y1, int x1, T value);
		int getcol();
		int getrow();
		double* sr();

	private:
		T** m;
		int row;
		int col;
};
Цитата:
Сообщение от xsix Посмотреть сообщение
Там подключено вот что:
vector.cpp
Код:
#include "StdAfx.h"
#include "vector.h"
matrix.cpp
Код:
#include "StdAfx.h"
#include "matrix.h"
Сам файл StdAfx.h есть и его регистр соответствует данному?
С++ очень чувствителен к регистру
stdafx не равно StdAfx
"SPACE.THE FINAL FRONTIER.This's a voyage of starship Enterprise. It's 5-year mission to explore strange new worlds,to seek out new life and civilizations,to boldly go where no man has gone before"
challengerr вне форума Ответить с цитированием
Старый 28.12.2008, 23:18   #25
xsix
Пользователь
 
Аватар для xsix
 
Регистрация: 27.12.2008
Сообщений: 20
По умолчанию

Есть. И в нём записано:
Код:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>
#include <windows.h>
#include <iostream>
#include <time.h>
	


// TODO: reference additional headers your program requires here
Ругается:
Код:
1>matrix.cpp
1>vector.cpp
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : error C2006: '#include' : expected a filename, found 'identifier'
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : fatal error C1083: Cannot open include file: '': No such file or directory
1>main.cpp
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : error C2006: '#include' : expected a filename, found 'identifier'
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : fatal error C1083: Cannot open include file: '': No such file or directory

Последний раз редактировалось xsix; 28.12.2008 в 23:32.
xsix вне форума Ответить с цитированием
Старый 29.12.2008, 00:15   #26
xsix
Пользователь
 
Аватар для xsix
 
Регистрация: 27.12.2008
Сообщений: 20
По умолчанию

Мда...Косяки за косяком. Время идёт, а задача так и осталась пробелом...

Последний раз редактировалось xsix; 29.12.2008 в 00:30.
xsix вне форума Ответить с цитированием
Старый 29.12.2008, 01:41   #27
challengerr
Участник клуба
 
Аватар для challengerr
 
Регистрация: 30.07.2008
Сообщений: 1,601
По умолчанию

Код:
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : error C2006: '#include' : expected a filename, found 'identifier'
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : fatal error C1083: Cannot open include file: '': No such file or directory
См. http://msdn.microsoft.com/en-us/library/dc232hsx.aspx

Он пишет, что заголовочный файл не найден. Проверь инклуды.
"SPACE.THE FINAL FRONTIER.This's a voyage of starship Enterprise. It's 5-year mission to explore strange new worlds,to seek out new life and civilizations,to boldly go where no man has gone before"

Последний раз редактировалось challengerr; 29.12.2008 в 01:43.
challengerr вне форума Ответить с цитированием
Старый 29.12.2008, 02:28   #28
StarWorm
Форумчанин
 
Регистрация: 17.11.2008
Сообщений: 233
По умолчанию

Мда... Он у тебя ругается то на файл vector.h, а ты вставки кода совершенно другие сделал! И как тебе после этого помогать...
Что написано во второй (2) строчке файла vector.h???
StarWorm вне форума Ответить с цитированием
Старый 29.12.2008, 10:24   #29
xsix
Пользователь
 
Аватар для xsix
 
Регистрация: 27.12.2008
Сообщений: 20
По умолчанию

Выложу всё по отдельности.
Вот файл vector.h
Код:
#pragma once
#include <stdafx.h>

template <class V>
class vector
{
public:
	void print_vector(V m, int sz)
};
stdafx.h
Код:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <windows.h>
#include <time.h>
#include <iostream>

	


// TODO: reference additional headers your program requires here
matrix.h
Код:
#pragma once

template <class T>
class matrix
{
public:
    matrix(int rows, int columns);
    ~matrix();
    void manually_set();
    void print();
    void random();
    void set_from_array(T* k);           
    T get_by_index(int y,int x);
    void swap_values(int y1,int x1, int y2,int x2);
    void set_value(int y1, int x1, T value);
    int getcol();
    int getrow();
    double* sr();

   private:
                T** m;
                int row;
                int col;


};

main.cpp
Код:
#include <stdafx.h>
#include "matrix.h"
#include "vector.h"
#include <iostream>
#include <cstdio>

using namespace std;

void main()
{
        int x,y;
		cout<<"Vvedite kol-vo strok: ";
        cin >> x; // строк
		cout<<"Vvedite kol-vo stolbzov: ";
        cin >> y; // столбцов
        matrix<int> tr(x,y);
        double* res;
		tr.random();
        tr.print();
        res = tr.sr();
        cout<<"\n";
		cout<<"Nash vector:"<<"/n";
        print_vector(res,tr.getcol());
		  return 0;
}
vector.cpp
Код:
#include <stdafx.h>
#include "vector.h"
#include <iostream>



template <class V>
void print_vector<V>(V m, int sz)
{
        int i;
        for (i=0 ; i<sz; i++)
        {
                cout << m[i] <<"  ";

        }
        cout <<"\n";

}
matrix.cpp
Код:
#include <stdafx.h>
#include "matrix.h"
#include <iostream>



template <class T>
 matrix<T>::matrix(int rows, int columns)
{
        int i;
        if (rows>0 && columns >0)
        {
                m=new T*[rows];
                for (i=0;i<rows;i++)
                {
                        m[i]=new T[columns];
                }
        }
        row=rows;
        col=columns;

}
template <class T>
matrix<T>::~matrix()
{
        int i;
        for (i=0;i<row;i++)
                {
                        delete[] m[i];
                }
        
        delete[] m;

}
template <class T>
  void  matrix<T>::manually_set()
{
        int i,j;
        for (i=0;i<row;i++)
        {
                for (j=0;j<col;j++)
                {
                        cin >> m[i][j];
                }
                        
        }
}
template <class T>
void matrix<T>::random()
{
        int i,j;
        srand (time(NULL));

        for (i=0 ; i<row; i++)  
                for (j=0; j<col;j++)            
                        m[i][j]=rand()%10;

}
template <class T>
 int matrix<T>::getcol()
{
        return(col);
}

template <class T>
int matrix<T>::getrow()
{
        return(row);
}
template <class T>
double* matrix<T>::sr()
{
        double* result;
        int i,j,l;
        double sum;

        result=new double[col];
        l=0;

        for(i=0;i<col;i++)
        {
                sum=0;
                for (j=0;j<row;j++)
                {
                        sum+=m[j][i];
                }
                sum/=row;
                result[l]=sum;
                l++;
        }

        return(result);
}
template <class T>
 void matrix<T>::set_from_array( T* k)
{
        int i,j,l;

        for (i=0,l=0;i<row;i++)
        {
                for (j=0;j<col;j++)
                {
                        m[i][j]=k[l];                   
                        l++;
                }
                        
        }
}
template <class T>
void matrix<T>::set_value(int y1, int x1, T value)
{
        m[y1][x1]=value;
}
 template <class T>
 T  matrix<T>::get_by_index(int i,int j)
{
        if (i>=0 && j>=0 && i<row && j<col)
        {
                return(m[i][j]);
        }
        else
                return(-1);
}
template <class T>
void matrix<T>::print()
{
        int i,j;
        for (i=0;i<row;i++)
        {
                for (j=0;j<col;j++)
                {
                        cout << m[i][j] << "  ";
                }
                cout << "\n";
                        
        }
}
template <class T>
void matrix<T>::swap_values(int y1,int x1, int y2,int x2)
{
        T temp;
        temp=m[y1][x1];
        m[y1][x1]=m[y2][x2];
        m[y2][x2]=temp;

}

Последний раз редактировалось xsix; 29.12.2008 в 10:32.
xsix вне форума Ответить с цитированием
Старый 29.12.2008, 10:33   #30
xsix
Пользователь
 
Аватар для xsix
 
Регистрация: 27.12.2008
Сообщений: 20
По умолчанию

stdafx.cpp
Код:
// stdafx.cpp : source file that includes just the standard includes
// N2.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

И при этом вот такая картина:
Код:
1>main.cpp
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
1>vector.cpp
1>e:\documents and settings\coding\рабочий стол\c++\n2\n2\vector.h(2) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory

Последний раз редактировалось xsix; 29.12.2008 в 10:44.
xsix вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Двумерный массив Анжелика Помощь студентам 3 29.12.2008 21:23
Двумерный массив... Seriy8888 Паскаль, Turbo Pascal, PascalABC.NET 1 24.12.2008 21:26
Двумерный массив в С++ Draid Помощь студентам 2 07.03.2008 22:06
Двумерный массив help Imperceptible Паскаль, Turbo Pascal, PascalABC.NET 25 02.03.2007 20:00