Модераторы: Partizan, gambit
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> std::vector, visual studio 2005 
:(
    Опции темы
Metalex
Дата 21.1.2012, 14:57 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 635
Регистрация: 22.10.2008
Где: Украина-ZPсity

Репутация: нет
Всего: нет



При использовании вектора получаю кучу ошибок.

Код

#pragma once
#include "WResource.h"
#include <vector>

using namespace std;

class Catalog
{
    vector<WResource> catalog;
public:
    Catalog(void);
    void add(String ^ name, String ^ type, int volume, String ^ placement, int maxdepth, String ^ shortinfo);
    void show();
    void searchName(String ^ name);
    void searchType(String ^ type);
    void searchVolume(int volume);
    void searchPlacement(String ^ placement);
    void searchMaxdepth(int maxdepth);
};


Код

void Catalog::add(String ^ name, String ^ type, int volume, String ^ placement, int maxdepth, String ^ shortinfo) {
    WResource wr(name, type, volume, placement, maxdepth, shortinfo);
    catalog.push_back(wr);
}


Код

1>------ Build started: Project: WaterResources, Configuration: Debug Win32 ------
1>Compiling...
1>Catalog.cpp
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\xmemory(96) : error C3699: '*' : cannot use this indirection on type 'WResource'
1>        compiler replacing '*' with '^' to continue parsing
1>        D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(416) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled
1>        with
1>        [
1>            _Ty=WResource
1>        ]
1>        D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(426) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled
1>        with
1>        [
1>            _Ty=WResource,
1>            _Alloc=std::allocator<WResource>
1>        ]
1>        d:\all are here\!заказы\waterresources\waterresources\Catalog.h(9) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1>        with
1>        [
1>            _Ty=WResource
1>        ]
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\xmemory(97) : error C3699: '&' : cannot use this indirection on type 'WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\xmemory(98) : error C3699: '*' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '*' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\xmemory(99) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\xmemory(154) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(473) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(479) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(531) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(785) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(846) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(851) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(858) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(1058) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(1116) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(1206) : error C3699: '&' : cannot use this indirection on type 'const WResource'
1>        compiler replacing '&' with '^' to continue parsing
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(1243) : error C3265: cannot declare a managed '_Myfirst' in an unmanaged 'std::vector<_Ty>'
1>        with
1>        [
1>            _Ty=WResource
1>        ]
1>        may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(1244) : error C3265: cannot declare a managed '_Mylast' in an unmanaged 'std::vector<_Ty>'
1>        with
1>        [
1>            _Ty=WResource
1>        ]
1>        may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>D:\Program Files (x86)\Visual Studio 2005 (8)\VC\include\vector(1245) : error C3265: cannot declare a managed '_Myend' in an unmanaged 'std::vector<_Ty>'
1>        with
1>        [
1>            _Ty=WResource
1>        ]
1>        may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap
1>Build log was saved at "file://d:\All are here\!Заказы\WaterResources\WaterResources\Debug\BuildLog.htm"
1>WaterResources - 18 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



Помогите разобраться, пожалуйста.

Это сообщение отредактировал(а) Metalex - 21.1.2012, 14:57


--------------------
Don't let the system get you down.
PM WWW ICQ Skype   Вверх
Albor
Дата 21.1.2012, 15:45 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 589
Регистрация: 28.2.2009

Репутация: нет
Всего: 9



На каком языке пишешь? Похоже на не совместимость с вектором, поскольку компилятор пытается поменять *  на ^ при использовании WResource.
PM MAIL ICQ   Вверх
mes
Дата 21.1.2012, 17:15 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


любитель
****


Профиль
Группа: Участник Клуба
Сообщений: 7954
Регистрация: 14.1.2006

Репутация: 1
Всего: 250



Metalex, для управляемых типов (.net) предназначен другой вектор : http://msdn.microsoft.com/en-us/library/bb386284.aspx
Цитата

Header: <cliext/vector>
Namespace: cliext



--------------------
PM MAIL WWW   Вверх
Metalex
Дата 21.1.2012, 19:23 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 635
Регистрация: 22.10.2008
Где: Украина-ZPсity

Репутация: нет
Всего: нет



Я пишу на с++. А почему обычный вектор не подходит?


--------------------
Don't let the system get you down.
PM WWW ICQ Skype   Вверх
mes
Дата 21.1.2012, 19:26 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


любитель
****


Профиль
Группа: Участник Клуба
Сообщений: 7954
Регистрация: 14.1.2006

Репутация: 1
Всего: 250



Цитата(Metalex @  21.1.2012,  18:23 Найти цитируемый пост)
Я пишу на с++. А почему обычный вектор не подходит? 

потому что приведенный выше код не на c++, а на c++/cli для .net



--------------------
PM MAIL WWW   Вверх
Metalex
Дата 21.1.2012, 19:53 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 635
Регистрация: 22.10.2008
Где: Украина-ZPсity

Репутация: нет
Всего: нет



Цитата(mes @  21.1.2012,  19:26 Найти цитируемый пост)
для .net

Т.е. создав обычное приложение windows forms я создал приложение для .net?


--------------------
Don't let the system get you down.
PM WWW ICQ Skype   Вверх
Dem_max
Дата 21.1.2012, 19:58 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
***


Профиль
Группа: Завсегдатай
Сообщений: 1780
Регистрация: 12.4.2007

Репутация: нет
Всего: 39



да


--------------------
Американские программисты долго не могли понять, почему русские при зависании Windоws всё время повторяют "Твой зайка написал" ("Yоur bunnу wrоte")
PM MAIL   Вверх
Metalex
Дата 22.1.2012, 03:10 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 635
Регистрация: 22.10.2008
Где: Украина-ZPсity

Репутация: нет
Всего: нет



Но это подходит только для 8й и 10й студии. Есть ли аналог для 5й?


--------------------
Don't let the system get you down.
PM WWW ICQ Skype   Вверх
Metalex
Дата 22.1.2012, 13:16 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 635
Регистрация: 22.10.2008
Где: Украина-ZPсity

Репутация: нет
Всего: нет



Или кто знает, подскажите, пожалуйста, как обойти данную несправедливость..


--------------------
Don't let the system get you down.
PM WWW ICQ Skype   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Прежде чем создать тему, посмотрите сюда:
Partizan
PashaPash

Используйте теги [code=csharp][/code] для подсветки кода. Используйтe чекбокс "транслит" если у Вас нет русских шрифтов.
Что делать если Вам помогли, но отблагодарить помощника плюсом в репутацию Вы не можете(не хватает сообщений)? Пишите сюда, или отправляйте репорт. Поставим :)
Так же не забывайте отмечать свой вопрос решенным, если он таковым является :)


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, mr.DUDA, Partizan, PashaPash.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | .NET для новичков | Следующая тема »


 




[ Время генерации скрипта: 0.0496 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.