Search Results

Search found 3389 results on 136 pages for 'const'.

Page 12/136 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Why this function overloading is not working?

    - by Jack
    class CConfFile { public: CConfFile(const std::string &FileName); ~CConfFile(); ... std::string GetString(const std::string &Section, const std::string &Key); void GetString(const std::string &Section, const std::string &Key, char *Buffer, unsigned int BufferSize); ... } string CConfFile::GetString(const string &Section, const string &Key) { return GetKeyValue(Section, Key); } void GetString(const string &Section, const string &Key, char *Buffer, unsigned int BufferSize) { string Str = GetString(Section, Key); // *** ERROR *** strncpy(Buffer, Str.c_str(), Str.size()); } Why do I get an error too few arguments to function ‘void GetString(const std::string&, const std::string&, char*, unsigned int)' at the second function ? Thanks

    Read the article

  • libstdc++ - compiling failing because of tr1/regex

    - by Radek Šimko
    I have these packages installed on my OpenSUSE 11.3: i | libstdc++45 | Standard shared library for C++ | package i | libstdc++45-devel | Contains files and libraries for development | package But when i'm trying to compile this C++ code: #include <stdio.h> #include <tr1/regex> using namespace std; int main() { int test[2]; const tr1::regex pattern(".*"); test[0] = 1; if (tr1::regex_match("anything", pattern) == false) { printf("Pattern does not match.\n"); } return 0; } using g++ -pedantic -g -O1 -o ./main.o ./main.cpp It outputs this errors: ./main.cpp: In function ‘int main()’: ./main.cpp:13:43: error: ‘printf’ was not declared in this scope radek@mypc:~> nano main.cpp radek@mypc:~> g++ -pedantic -g -O1 -o ./main.o ./main.cpp /tmp/cc0g3GUE.o: In function `basic_regex': /usr/include/c++/4.5/tr1_impl/regex:771: undefined reference to `std::tr1::basic_regex<char, std::tr1::regex_traits<char> >::_M_compile()' /tmp/cc0g3GUE.o: In function `bool std::tr1::regex_match<char const*, char, std::tr1::regex_traits<char> >(char const*, char const*, std::tr1::basic_regex<char, std::tr1::regex_traits<char> > const&, std::bitset<11u>)': /usr/include/c++/4.5/tr1_impl/regex:2144: undefined reference to `bool std::tr1::regex_match<char const*, std::allocator<std::tr1::sub_match<char const*> >, char, std::tr1::regex_traits<char> >(char const*, char const*, std::tr1::match_results<char const*, std::allocator<std::tr1::sub_match<char const*> > >&, std::tr1::basic_regex<char, std::tr1::regex_traits<char> > const&, std::bitset<11u>)' collect2: ld returned 1 exit status What packages should i (un)install to make the code work on my PC?

    Read the article

  • how I can overcome this error C2679: binary '>>' : no operator found which takes a right-hand oper

    - by hussein abdullah
    #include <iostream> using std::cout; using std::cin; using std::endl; #include <cstring> void initialize(char[],int*); void input(const char[] ,int&); void print ( const char*,const int); void growOlder (const char [], int* ); bool comparePeople(const char* ,const int*,const char*,const int*); int main(){ char name1[25]; char name2[25]; int age1; int age2; initialize (name1,&age1); initialize (name2,&age2); print(name1,age1); print(name2,age2); input(name1,age1); input(name2,age2); print(name1,age1); print(name2,age2); growOlder(name2,&age2); if(comparePeople(name1,&age1,name2,&age2)) cout<<"Both People have the same name and age "<<endl; return 0; } void input(const char name[],int &age) { cout<<"Enter a name :"; cin>>name ; cout<<"Enter an age:"; cin>>age; cout<<endl; } void initialize ( char name[],int *age) { name[0]='\0'; *age=0; } void print ( const char name[],const int age ) { cout<<"The Value stored in variable name is :" <<name<<endl <<"The Value stored in variable age is :" <<age<<endl<<endl; } void growOlder(const char name[],int *age) { cout<< name <<" has grown one year older\n\n"; *age++; } bool comparePeople (const char *name1,const int *age1, const char *name2,const int *age2) { return(*age1==*age2 && !strcmp(name1,name2)); }

    Read the article

  • how to solve the errors of this program

    - by hussein abdullah
    include using std::cout; using std::cin; using std::endl; include void initialize(char[],int*); void input(const char[] ,int&); void print ( const char*,const int); void growOlder (const char [], int* ); bool comparePeople(const char* ,const int*,const char*,const int*); int main(){ char name1[25]; char name2[25]; int age1; int age2; initialize (name1,&age1); initialize (name2,&age2); print(name1,*age1); print(name2,*age2); input(name1,age1); input(name2,age2); print(&name1,&age1); print(&name2,&age2); growOlder(name2,age2); if(comparePeople(name1,&age1,name2,&age2)) cout<<"Both People have the same name and age "<<endl; return 0; } void input(const char name[],int &age) { cout<<"Enter a name :"; cinname ; cout<<"Enter an age:"; cin>>age; cout<<endl; } void initialize ( char name[],int *age) { name=""; age=0; } void print ( const char name[],const int age ) { cout<<"The Value stored in variable name is :" < void growOlder(const char name[],int *age) { cout<< name <<" has grown one year older\n\n"; *age++; } bool comparePeople (const char *name1,const int *age1, const char *name2,const int *age2) { return(age1==age2 &&strcmp(name1,name2)); }

    Read the article

  • Optimize MySQL query (ngrams, COUNT(), GROUP BY, ORDER BY)

    - by Gerardo
    I have a database with thousands of companies and their locations. I have implemented n-grams to optimize search. I am making one query to retrieve all the companies that match with the search query and another one to get a list with their locations and the number of companies in each location. The query I am trying to optimize is the latter. Maybe the problem is this: Every company ('anunciante') has a field ('estado') to make logical deletes. So, if 'estado' equals 1, the company should be retrieved. When I run the EXPLAIN command, it shows that it goes through almost 40k rows, when the actual result (the reality matching companies) are 80. How can I optimize this? This is my query (XXX represent the n-grams for the search query): SELECT provincias.provincia AS provincia, provincias.id, COUNT(*) AS cantidad FROM anunciantes JOIN anunciante_invertido AS a_i0 ON anunciantes.id = a_i0.id_anunciante JOIN indice_invertido AS indice0 ON a_i0.id_invertido = indice0.id LEFT OUTER JOIN domicilios ON anunciantes.id = domicilios.id_anunciante LEFT OUTER JOIN localidades ON domicilios.id_localidad = localidades.id LEFT OUTER JOIN provincias ON provincias.id = localidades.id_provincia WHERE anunciantes.estado = 1 AND indice0.id IN (SELECT invertido_ngrama.id_palabra FROM invertido_ngrama JOIN ngrama ON ngrama.id = invertido_ngrama.id_ngrama WHERE ngrama.ngrama = 'XXX') AND indice0.id IN (SELECT invertido_ngrama.id_palabra FROM invertido_ngrama JOIN ngrama ON ngrama.id = invertido_ngrama.id_ngrama WHERE ngrama.ngrama = 'XXX') AND indice0.id IN (SELECT invertido_ngrama.id_palabra FROM invertido_ngrama JOIN ngrama ON ngrama.id = invertido_ngrama.id_ngrama WHERE ngrama.ngrama = 'XXX') AND indice0.id IN (SELECT invertido_ngrama.id_palabra FROM invertido_ngrama JOIN ngrama ON ngrama.id = invertido_ngrama.id_ngrama WHERE ngrama.ngrama = 'XXX') AND indice0.id IN (SELECT invertido_ngrama.id_palabra FROM invertido_ngrama JOIN ngrama ON ngrama.id = invertido_ngrama.id_ngrama WHERE ngrama.ngrama = 'XXX') GROUP BY provincias.id ORDER BY cantidad DESC And this is the query explained (hope it can be read in this format): id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY anunciantes ref PRIMARY,estado estado 1 const 36669 Using index; Using temporary; Using filesort 1 PRIMARY domicilios ref id_anunciante id_anunciante 4 db84771_viaempresas.anunciantes.id 1 1 PRIMARY localidades eq_ref PRIMARY PRIMARY 4 db84771_viaempresas.domicilios.id_localidad 1 1 PRIMARY provincias eq_ref PRIMARY PRIMARY 4 db84771_viaempresas.localidades.id_provincia 1 1 PRIMARY a_i0 ref PRIMARY,id_anunciante,id_invertido PRIMARY 4 db84771_viaempresas.anunciantes.id 1 Using where; Using index 1 PRIMARY indice0 eq_ref PRIMARY PRIMARY 4 db84771_viaempresas.a_i0.id_invertido 1 Using index 6 DEPENDENT SUBQUERY ngrama const PRIMARY,ngrama ngrama 5 const 1 Using index 6 DEPENDENT SUBQUERY invertido_ngrama eq_ref PRIMARY,id_palabra,id_ngrama PRIMARY 8 func,const 1 Using index 5 DEPENDENT SUBQUERY ngrama const PRIMARY,ngrama ngrama 5 const 1 Using index 5 DEPENDENT SUBQUERY invertido_ngrama eq_ref PRIMARY,id_palabra,id_ngrama PRIMARY 8 func,const 1 Using index 4 DEPENDENT SUBQUERY ngrama const PRIMARY,ngrama ngrama 5 const 1 Using index 4 DEPENDENT SUBQUERY invertido_ngrama eq_ref PRIMARY,id_palabra,id_ngrama PRIMARY 8 func,const 1 Using index 3 DEPENDENT SUBQUERY ngrama const PRIMARY,ngrama ngrama 5 const 1 Using index 3 DEPENDENT SUBQUERY invertido_ngrama eq_ref PRIMARY,id_palabra,id_ngrama PRIMARY 8 func,const 1 Using index 2 DEPENDENT SUBQUERY ngrama const PRIMARY,ngrama ngrama 5 const 1 Using index 2 DEPENDENT SUBQUERY invertido_ngrama eq_ref PRIMARY,id_palabra,id_ngrama PRIMARY 8 func,const 1 Using index

    Read the article

  • C++ [] array operator with multiple arguments?

    - by genesys
    Can I define in C++ an array operator that takes multiple arguments? I tried it like this: const T& operator[](const int i, const int j, const int k) const{ return m_cells[k*m_resSqr+j*m_res+i]; } T& operator[](const int i, const int j, const int k){ return m_cells[k*m_resSqr+j*m_res+i]; } But I'm getting this error: error C2804 binary operator '[' has too many parameters

    Read the article

  • How to layout class definition when inheriting from multiple interfaces

    - by gabr
    Given two interface definitions ... IOmniWorkItem = interface ['{3CE2762F-B7A3-4490-BF22-2109C042EAD1}'] function GetData: TOmniValue; function GetResult: TOmniValue; function GetUniqueID: int64; procedure SetResult(const value: TOmniValue); // procedure Cancel; function DetachException: Exception; function FatalException: Exception; function IsCanceled: boolean; function IsExceptional: boolean; property Data: TOmniValue read GetData; property Result: TOmniValue read GetResult write SetResult; property UniqueID: int64 read GetUniqueID; end; IOmniWorkItemEx = interface ['{3B48D012-CF1C-4B47-A4A0-3072A9067A3E}'] function GetOnWorkItemDone: TOmniWorkItemDoneDelegate; function GetOnWorkItemDone_Asy: TOmniWorkItemDoneDelegate; procedure SetOnWorkItemDone(const Value: TOmniWorkItemDoneDelegate); procedure SetOnWorkItemDone_Asy(const Value: TOmniWorkItemDoneDelegate); // property OnWorkItemDone: TOmniWorkItemDoneDelegate read GetOnWorkItemDone write SetOnWorkItemDone; property OnWorkItemDone_Asy: TOmniWorkItemDoneDelegate read GetOnWorkItemDone_Asy write SetOnWorkItemDone_Asy; end; ... what are your ideas of laying out class declaration that inherits from both of them? My current idea (but I don't know if I'm happy with it): TOmniWorkItem = class(TInterfacedObject, IOmniWorkItem, IOmniWorkItemEx) strict private FData : TOmniValue; FOnWorkItemDone : TOmniWorkItemDoneDelegate; FOnWorkItemDone_Asy: TOmniWorkItemDoneDelegate; FResult : TOmniValue; FUniqueID : int64; strict protected procedure FreeException; protected //IOmniWorkItem function GetData: TOmniValue; function GetResult: TOmniValue; function GetUniqueID: int64; procedure SetResult(const value: TOmniValue); protected //IOmniWorkItemEx function GetOnWorkItemDone: TOmniWorkItemDoneDelegate; function GetOnWorkItemDone_Asy: TOmniWorkItemDoneDelegate; procedure SetOnWorkItemDone(const Value: TOmniWorkItemDoneDelegate); procedure SetOnWorkItemDone_Asy(const Value: TOmniWorkItemDoneDelegate); public constructor Create(const data: TOmniValue; uniqueID: int64); destructor Destroy; override; public //IOmniWorkItem procedure Cancel; function DetachException: Exception; function FatalException: Exception; function IsCanceled: boolean; function IsExceptional: boolean; property Data: TOmniValue read GetData; property Result: TOmniValue read GetResult write SetResult; property UniqueID: int64 read GetUniqueID; public //IOmniWorkItemEx property OnWorkItemDone: TOmniWorkItemDoneDelegate read GetOnWorkItemDone write SetOnWorkItemDone; property OnWorkItemDone_Asy: TOmniWorkItemDoneDelegate read GetOnWorkItemDone_Asy write SetOnWorkItemDone_Asy; end; As noted in answers, composition is a good approach for this example but I'm not sure it applies in all cases. Sometimes I'm using multiple inheritance just to split read and write access to some property into public (typically read-only) and private (typically write-only) part. Does composition still apply here? I'm not really sure as I would have to move the property in question out from the main class and I'm not sure that's the correct way to do it. Example: // public part of the interface interface IOmniWorkItemConfig = interface function OnExecute(const aTask: TOmniBackgroundWorkerDelegate): IOmniWorkItemConfig; function OnRequestDone(const aTask: TOmniWorkItemDoneDelegate): IOmniWorkItemConfig; function OnRequestDone_Asy(const aTask: TOmniWorkItemDoneDelegate): IOmniWorkItemConfig; end; // private part of the interface IOmniWorkItemConfigEx = interface ['{42CEC5CB-404F-4868-AE81-6A13AD7E3C6B}'] function GetOnExecute: TOmniBackgroundWorkerDelegate; function GetOnRequestDone: TOmniWorkItemDoneDelegate; function GetOnRequestDone_Asy: TOmniWorkItemDoneDelegate; end; // implementing class TOmniWorkItemConfig = class(TInterfacedObject, IOmniWorkItemConfig, IOmniWorkItemConfigEx) strict private FOnExecute : TOmniBackgroundWorkerDelegate; FOnRequestDone : TOmniWorkItemDoneDelegate; FOnRequestDone_Asy: TOmniWorkItemDoneDelegate; public constructor Create(defaults: IOmniWorkItemConfig = nil); public //IOmniWorkItemConfig function OnExecute(const aTask: TOmniBackgroundWorkerDelegate): IOmniWorkItemConfig; function OnRequestDone(const aTask: TOmniWorkItemDoneDelegate): IOmniWorkItemConfig; function OnRequestDone_Asy(const aTask: TOmniWorkItemDoneDelegate): IOmniWorkItemConfig; public //IOmniWorkItemConfigEx function GetOnExecute: TOmniBackgroundWorkerDelegate; function GetOnRequestDone: TOmniWorkItemDoneDelegate; function GetOnRequestDone_Asy: TOmniWorkItemDoneDelegate; end;

    Read the article

  • Is it a good idea to return " const char * " from a function?

    - by AJ
    Now I have a function that has to return a string. I saw a particular implementation where he returns a const char * from the function. Something like this: const char * GetSomeString() { ........ return somestlstring.c_str(); } SomeOtherFoo () { const char * tmp = GetSomeString(); string s = tmp; } Now I felt there is something potentially wrong with this. Is my gut feel right? or Is this a perfectly safe code? Kindly give me ur suggestions. I have a feeling return const char * this way might result in havoc.. Thanks, Arjun

    Read the article

  • why no implicit conversion from pointer to reference to const pointer.

    - by user316606
    I'll illustrate my question with code: #include <iostream> void PrintInt(const unsigned char*& ptr) { int data = 0; ::memcpy(&data, ptr, sizeof(data)); // advance the pointer reference. ptr += sizeof(data); std::cout << std::hex << data << " " << std::endl; } int main(int, char**) { unsigned char buffer[] = { 0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x22, }; /* const */ unsigned char* ptr = buffer; PrintInt(ptr); // error C2664: ... PrintInt(ptr); // error C2664: ... return 0; } When I run this code (in VS2008) I get this: error C2664: 'PrintInt' : cannot convert parameter 1 from 'unsigned char *' to 'const unsigned char *&'. If I uncomment the "const" comment it works fine. However shouldn't pointer implicitly convert into const pointer and then reference be taken? Am I wrong in expecting this to work? Thanks!

    Read the article

  • Binary Cosine Cofficient

    - by hairyyak
    I was given the following forumulae for calculating this sim=|QnD| / v|Q|v|D| I went ahed and implemented a class to compare strings consisting of a series of words #pragma once #include <vector> #include <string> #include <iostream> #include <vector> using namespace std; class StringSet { public: StringSet(void); StringSet( const string the_strings[], const int no_of_strings); ~StringSet(void); StringSet( const vector<string> the_strings); void add_string( const string the_string); bool remove_string( const string the_string); void clear_set(void); int no_of_strings(void) const; friend ostream& operator <<(ostream& outs, StringSet& the_strings); friend StringSet operator *(const StringSet& first, const StringSet& second); friend StringSet operator +(const StringSet& first, const StringSet& second); double binary_coefficient( const StringSet& the_second_set); private: vector<string> set; }; #include "StdAfx.h" #include "StringSet.h" #include <iterator> #include <algorithm> #include <stdexcept> #include <iostream> #include <cmath> StringSet::StringSet(void) { } StringSet::~StringSet(void) { } StringSet::StringSet( const vector<string> the_strings) { set = the_strings; } StringSet::StringSet( const string the_strings[], const int no_of_strings) { copy( the_strings, &the_strings[no_of_strings], back_inserter(set)); } void StringSet::add_string( const string the_string) { try { if( find( set.begin(), set.end(), the_string) == set.end()) { set.push_back(the_string); } else { //String is already in the set. throw domain_error("String is already in the set"); } } catch( domain_error e) { cout << e.what(); exit(1); } } bool StringSet::remove_string( const string the_string) { //Found the occurrence of the string. return it an iterator pointing to it. vector<string>::iterator iter; if( ( iter = find( set.begin(), set.end(), the_string) ) != set.end()) { set.erase(iter); return true; } return false; } void StringSet::clear_set(void) { set.clear(); } int StringSet::no_of_strings(void) const { return set.size(); } ostream& operator <<(ostream& outs, StringSet& the_strings) { vector<string>::const_iterator const_iter = the_strings.set.begin(); for( ; const_iter != the_strings.set.end(); const_iter++) { cout << *const_iter << " "; } cout << endl; return outs; } //This function returns the union of the two string sets. StringSet operator *(const StringSet& first, const StringSet& second) { vector<string> new_string_set; new_string_set = first.set; for( unsigned int i = 0; i < second.set.size(); i++) { vector<string>::const_iterator const_iter = find(new_string_set.begin(), new_string_set.end(), second.set[i]); //String is new - include it. if( const_iter == new_string_set.end() ) { new_string_set.push_back(second.set[i]); } } StringSet the_set(new_string_set); return the_set; } //This method returns the intersection of the two string sets. StringSet operator +(const StringSet& first, const StringSet& second) { //For each string in the first string look though the second and see if //there is a matching pair, in which case include the string in the set. vector<string> new_string_set; vector<string>::const_iterator const_iter = first.set.begin(); for ( ; const_iter != first.set.end(); ++const_iter) { //Then search through the entire second string to see if //there is a duplicate. vector<string>::const_iterator const_iter2 = second.set.begin(); for( ; const_iter2 != second.set.end(); const_iter2++) { if( *const_iter == *const_iter2 ) { new_string_set.push_back(*const_iter); } } } StringSet new_set(new_string_set); return new_set; } double StringSet::binary_coefficient( const StringSet& the_second_set) { double coefficient; StringSet intersection = the_second_set + set; coefficient = intersection.no_of_strings() / sqrt((double) no_of_strings()) * sqrt((double)the_second_set.no_of_strings()); return coefficient; } However when I try and calculate the coefficient using the following main function: // Exercise13.cpp : main project file. #include "stdafx.h" #include <boost/regex.hpp> #include "StringSet.h" using namespace System; using namespace System::Runtime::InteropServices; using namespace boost; //This function takes as input a string, which //is then broken down into a series of words //where the punctuaction is ignored. StringSet break_string( const string the_string) { regex re; cmatch matches; StringSet words; string search_pattern = "\\b(\\w)+\\b"; try { // Assign the regular expression for parsing. re = search_pattern; } catch( regex_error& e) { cout << search_pattern << " is not a valid regular expression: \"" << e.what() << "\"" << endl; exit(1); } sregex_token_iterator p(the_string.begin(), the_string.end(), re, 0); sregex_token_iterator end; for( ; p != end; ++p) { string new_string(p->first, p->second); String^ copy_han = gcnew String(new_string.c_str()); String^ copy_han2 = copy_han->ToLower(); char* str2 = (char*)(void*)Marshal::StringToHGlobalAnsi(copy_han2); string new_string2(str2); words.add_string(new_string2); } return words; } int main(array<System::String ^> ^args) { StringSet words = break_string("Here is a string, with some; words"); StringSet words2 = break_string("There is another string,"); cout << words.binary_coefficient(words2); return 0; } I get an index which is 1.5116 rather than a value from 0 to 1. Does anybody have a clue why this is the case? Any help would be appreciated.

    Read the article

  • How do you return a pointer to a base class with a virtual function?

    - by Nick Sweet
    I have a base class called Element, a derived class called Vector, and I'm trying to redefine two virtual functions from Element in Vector. //element.h template <class T> class Element { public: Element(); virtual Element& plus(const Element&); virtual Element& minus(const Element&); }; and in another file //Vector.h #include "Element.h" template <class T> class Vector: public Element<T> { T x, y, z; public: //constructors Vector(); Vector(const T& x, const T& y = 0, const T& z =0); Vector(const Vector& u); ... //operations Element<T>& plus(const Element<T>& v) const; Element<T>& minus(const Element<T>& v) const; ... }; //sum template <class T> Element<T>& Vector<T>::plus(const Element<T>& v) const { Element<T>* ret = new Vector((x + v.x), (y + v.y), (z + v.z)); return *ret; } //difference template <class T> Element<T>& Vector<T>::minus(const Element<T>& v) const { Vector<T>* ret = new Vector((x - v.x), (y - v.y), (z - v.z)); return *ret; } but I always get error: 'const class Element' has no member named 'getx' So, can I define my virtual functions to take Vector& as an argument instead, or is there a way for me to access the data members of Vector through a pointer to Element? I'm still fairly new to inheritance polymorphism, fyi.

    Read the article

  • (C++) What's the difference between these overloaded operator functions?

    - by cv3000
    What is the difference between these two ways of overloading the != operator below. Which is consider better? Class Test { ...// private: int iTest public: BOOL operator==(const &Test test) const; BOOL operator!=(const &Test test) const; } BOOL operator==(const &Test test) const { return (iTest == test.iTest); } //overload function 1 BOOL Test::operator!=(const &Test test) const { return !operator==(test); } //overload function 2 BOOL Test::operator!=(const &Test test) const { return (iTest != test.iTest); } I've just recently seen function 1's syntax for calling a sibling operator function and wonder if writing it that way provides any benefits.

    Read the article

  • scala 2.8.0.RC2 compiler problem on pattern matching statement?

    - by gruenewa
    Why does the following module not compile on Scala 2.8.RC[1,2]? object Test { import util.matching.Regex._ val pVoid = """\s*void\s*""".r val pVoidPtr = """\s*(const\s+)?void\s*\*\s*""".r val pCharPtr = """\s*(const\s+)GLchar\s*\*\s*""".r val pIntPtr = """\s*(const\s+)?GLint\s*\*\s*""".r val pUintPtr = """\s*(const\s+)?GLuint\s*\*\s*""".r val pFloatPtr = """\s*(const\s+)?GLfloat\s*\*\s*""".r val pDoublePtr = """\s*(const\s+)?GLdouble\s*\*\s*""".r val pShortPtr = """\s*(const\s+)?GLshort\s*\*\s*""".r val pUshortPtr = """\s*(const\s+)?GLushort\s*\*\s*""".r val pInt64Ptr = """\s*(const\s+)?GLint64\s*\*\s*""".r val pUint64Ptr = """\s*(const\s+)?GLuint64\s*\*\s*""".r def mapType(t: String): String = t.trim match { case pVoid() => "Unit" case pVoidPtr() => "ByteBuffer" case pCharPtr() => "CharBuffer" case pIntPtr() | pUintPtr() => "IntBuffer" case pFloatPtr() => "FloatBuffer" case pShortPtr() | pUshortPtr() => "ShortBuffer" case pDoublePtr() => "DoubleBuffer" case pInt64Ptr() | pUint64Ptr() => "LongBuffer" case x => x } }

    Read the article

  • QTreeView incorrectly displays the SpinBox if item is checkable and when using QWindowsStyle

    - by Sharraz
    Hello, I'm having a problem with a QTreeView in my program: The SpinBox used to edit the double value of a checkable item is displayed incorrectly when using the Windows style. Only the up and down buttons of the SpinBox can be seen, but not any value. The following example code is able to reproduce the problem: #include <QtGui> class Model : public QAbstractItemModel { public: Model() : checked(false), number(0) {} Qt::ItemFlags flags(const QModelIndex & index) const { return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable; } QVariant data(const QModelIndex &index, int role) const { switch (role) { case Qt::DisplayRole: case Qt::EditRole: return QVariant(number); case Qt::CheckStateRole: return QVariant(checked ? Qt::Checked : Qt::Unchecked); } return QVariant(); } QVariant headerData(int section, Qt::Orientation orientation, int role) const { return QVariant(); } int rowCount(const QModelIndex &parent) const { return parent.isValid() ? 0 : 1; } int columnCount(const QModelIndex &parent) const { return parent.isValid() ? 0 : 1; } bool setData(const QModelIndex &index, const QVariant &value, int role) { switch (role) { case Qt::EditRole: number = value.toDouble(); emit dataChanged(index, index); return true; case Qt::CheckStateRole: checked = value.toInt(); emit dataChanged(index, index); return true; } return false; } QModelIndex index(int row, int column, const QModelIndex &parent) const { if (!row && !column && !parent.isValid()) return createIndex(0, 0); return QModelIndex(); } QModelIndex parent(const QModelIndex &child) const { return QModelIndex(); } private: bool checked; double number; }; int main(int argc, char *argv[]) { QApplication app(argc, argv); QApplication::setStyle(new QWindowsStyle()); QTreeView tree; tree.setModel(new Model()); tree.show(); return app.exec(); } The problems seems to have something to do with the checkbox. If Qt::ItemIsUserCheckable is removed, the SpinBox will be displayed correctly. If the number is replaced by a longer one like 0.01, it can be seen partially. Any idea how this problem can be solved? Do I use the checkbox correctly? Greets, Sharraz

    Read the article

  • Texture errors in CubeMap

    - by shade4159
    I am trying to apply this texture as a cubemap. This is my result: Clearly I am doing something with my texture coordinates, but I cannot for the life of me figure out what. I don't even see a pattern to the texture fragments. They just seem like a jumble of different faces. Can anyone shed some light on this? Vertex shader: #version 400 in vec4 vPosition; in vec3 inTexCoord; smooth out vec3 texCoord; uniform mat4 projMatrix; void main() { texCoord = inTexCoord; gl_Position = projMatrix * vPosition; } My fragment shader: #version 400 smooth in vec3 texCoord; out vec4 fColor; uniform samplerCube textures void main() { fColor = texture(textures,texCoord); } Vertices of cube: point4 worldVerts[8] = { vec4( 15, 15, 15, 1 ), vec4( -15, 15, 15, 1 ), vec4( -15, 15, -15, 1 ), vec4( 15, 15, -15, 1 ), vec4( -15, -15, 15, 1 ), vec4( 15, -15, 15, 1 ), vec4( 15, -15, -15, 1 ), vec4( -15, -15, -15, 1 ) }; Cube rendering: void worldCube(point4* verts, int& Index, point4* points, vec3* texVerts) { quadInv( verts[0], verts[1], verts[2], verts[3], 1, Index, points, texVerts); quadInv( verts[6], verts[3], verts[2], verts[7], 2, Index, points, texVerts); quadInv( verts[4], verts[5], verts[6], verts[7], 3, Index, points, texVerts); quadInv( verts[4], verts[1], verts[0], verts[5], 4, Index, points, texVerts); quadInv( verts[5], verts[0], verts[3], verts[6], 5, Index, points, texVerts); quadInv( verts[4], verts[7], verts[2], verts[1], 6, Index, points, texVerts); } Backface function (since this is the inside of the cube): void quadInv( const point4& a, const point4& b, const point4& c, const point4& d , int& Index, point4* points, vec3* texVerts) { quad( a, d, c, b, Index, points, texVerts, a.to_3(), b.to_3(), c.to_3(), d.to_3()); } And the quad drawing function: void quad( const point4& a, const point4& b, const point4& c, const point4& d, int& Index, point4* points, vec3* texVerts, const vec3& tex_a, const vec3& tex_b, const vec3& tex_c, const vec3& tex_d) { texVerts[Index] = tex_a.normalized(); points[Index] = a; Index++; texVerts[Index] = tex_b.normalized(); points[Index] = b; Index++; texVerts[Index] = tex_c.normalized(); points[Index] = c; Index++; texVerts[Index] = tex_a.normalized(); points[Index] = a; Index++; texVerts[Index] = tex_c.normalized(); points[Index] = c; Index++; texVerts[Index] = tex_d.normalized(); points[Index] = d; Index++; } Edit: I forgot to mention, in the image, the camera is pointed directly at the back face of the cube. You can kind of see the diagonals leading out of the corners, if you squint.

    Read the article

  • How to send keypresses from qt application to libvlc

    - by anon
    I need to send keypresses from my application window to libvlc, how do i do that? I tried using varSetInteger but then i got the following error error: ‘var_SetInteger’ was not declared in this scope so i searched for the file in which var_SetInteger was defined and found that it was defined in vlc_variables.h so in included it and got the following error. What am i missing? ../vlc-0.9.10/include/vlc_variables.h:121: error: ‘__var_Create’ has not been declared ../vlc-0.9.10/include/vlc_variables.h:121: error: expected identifier before ‘(’ token ../vlc-0.9.10/include/vlc_variables.h:121: error: expected )' before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:121: error: expected ‘,’ or ‘...’ before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:121: error: expected constructor, destructor, or type conversion before ‘)’ token ../vlc-0.9.10/include/vlc_variables.h:122: error: ‘__var_Destroy’ has not been declared ../vlc-0.9.10/include/vlc_variables.h:122: error: expected identifier before ‘(’ token ../vlc-0.9.10/include/vlc_variables.h:122: error: expected )' before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:122: error: expected ‘,’ or ‘...’ before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:122: error: expected constructor, destructor, or type conversion before ‘)’ token ../vlc-0.9.10/include/vlc_variables.h:124: error: ‘__var_Change’ has not been declared ../vlc-0.9.10/include/vlc_variables.h:124: error: expected identifier before ‘(’ token ../vlc-0.9.10/include/vlc_variables.h:124: error: expected )' before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:124: error: expected ‘,’ or ‘...’ before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:124: error: expected constructor, destructor, or type conversion before ‘)’ token ../vlc-0.9.10/include/vlc_variables.h:126: error: ‘__var_Type’ has not been declared ../vlc-0.9.10/include/vlc_variables.h:126: error: expected identifier before ‘(’ token ../vlc-0.9.10/include/vlc_variables.h:126: error: expected )' before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:126: error: expected ‘,’ or ‘...’ before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:126: error: expected constructor, destructor, or type conversion before ‘)’ token ../vlc-0.9.10/include/vlc_variables.h:127: error: ‘__var_Set’ has not been declared ../vlc-0.9.10/include/vlc_variables.h:127: error: expected identifier before ‘(’ token ../vlc-0.9.10/include/vlc_variables.h:127: error: expected )' before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:127: error: expected ‘,’ or ‘...’ before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:127: error: expected constructor, destructor, or type conversion before ‘)’ token ../vlc-0.9.10/include/vlc_variables.h:128: error: ‘__var_Get’ has not been declared ../vlc-0.9.10/include/vlc_variables.h:128: error: expected identifier before ‘(’ token ../vlc-0.9.10/include/vlc_variables.h:128: error: expected )' before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:128: error: expected ‘,’ or ‘...’ before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:128: error: expected constructor, destructor, or type conversion before ‘)’ token ../vlc-0.9.10/include/vlc_variables.h:131: error: ‘__var_Command’ has not been declared ../vlc-0.9.10/include/vlc_variables.h:131: error: expected identifier before ‘(’ token ../vlc-0.9.10/include/vlc_variables.h:131: error: expected )' before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:131: error: expected ‘,’ or ‘...’ before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:131: error: expected constructor, destructor, or type conversion before ‘)’ token ../vlc-0.9.10/include/vlc_variables.h:133: error: expected constructor, destructor, or type conversion before ‘(’ token ../vlc-0.9.10/include/vlc_variables.h:171: error: ‘__var_AddCallback’ has not been declared ../vlc-0.9.10/include/vlc_variables.h:171: error: expected identifier before ‘(’ token ../vlc-0.9.10/include/vlc_variables.h:171: error: expected )' before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:171: error: expected ‘,’ or ‘...’ before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:171: error: expected constructor, destructor, or type conversion before ‘)’ token ../vlc-0.9.10/include/vlc_variables.h:172: error: ‘__var_DelCallback’ has not been declared ../vlc-0.9.10/include/vlc_variables.h:172: error: expected identifier before ‘(’ token ../vlc-0.9.10/include/vlc_variables.h:172: error: expected )' before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:172: error: expected ‘,’ or ‘...’ before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:172: error: expected constructor, destructor, or type conversion before ‘)’ token ../vlc-0.9.10/include/vlc_variables.h:173: error: ‘__var_TriggerCallback’ has not been declared ../vlc-0.9.10/include/vlc_variables.h:173: error: expected identifier before ‘(’ token ../vlc-0.9.10/include/vlc_variables.h:173: error: expected )' before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:173: error: expected ‘,’ or ‘...’ before ‘*’ token ../vlc-0.9.10/include/vlc_variables.h:173: error: expected constructor, destructor, or type conversion before ‘)’ token ../vlc-0.9.10/include/vlc_variables.h:201: error: ‘__var_SetInteger’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:201: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:201: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:201: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:201: error: expected primary-expression before ‘int’ ../vlc-0.9.10/include/vlc_variables.h:201: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:202: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:215: error: ‘__var_SetBool’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:215: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:215: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:215: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:215: error: expected primary-expression before ‘bool’ ../vlc-0.9.10/include/vlc_variables.h:215: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:216: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:229: error: ‘__var_SetTime’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:229: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:229: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:229: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:229: error: expected primary-expression before ‘i’ ../vlc-0.9.10/include/vlc_variables.h:229: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:230: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:243: error: ‘__var_SetFloat’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:243: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:243: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:243: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:243: error: expected primary-expression before ‘float’ ../vlc-0.9.10/include/vlc_variables.h:243: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:244: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:257: error: ‘__var_SetString’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:257: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:257: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:257: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:257: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:257: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:258: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:270: error: ‘__var_SetVoid’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:270: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:270: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:270: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:270: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:271: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:302: error: ‘__var_GetInteger’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:302: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:302: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:302: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:302: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:303: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:317: error: ‘__var_GetBool’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:317: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:317: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:317: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:317: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:318: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:332: error: ‘__var_GetTime’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:332: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:332: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:332: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:332: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:333: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:347: error: ‘__var_GetFloat’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:347: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:347: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:347: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:347: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:348: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:362: error: ‘__var_GetString’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:362: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:362: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:362: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:362: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:363: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:371: error: ‘__var_GetNonEmptyString’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:371: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:371: error: ‘obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:371: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:371: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:372: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:412: error: variable or field ‘__var_IncInteger’ declared void ../vlc-0.9.10/include/vlc_variables.h:412: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:412: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:412: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:424: error: variable or field ‘__var_DecInteger’ declared void ../vlc-0.9.10/include/vlc_variables.h:424: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:424: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:424: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:437: error: ‘__var_CreateGetInteger’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:437: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:437: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:437: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:437: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:438: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:449: error: ‘__var_CreateGetBool’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:449: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:449: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:449: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:449: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:450: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:461: error: ‘__var_CreateGetTime’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:461: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:461: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:461: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:461: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:462: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:473: error: ‘__var_CreateGetFloat’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:473: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:473: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:473: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:473: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:474: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:485: error: ‘__var_CreateGetString’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:485: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:485: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:486: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:486: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:487: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:492: error: ‘__var_CreateGetNonEmptyString’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:492: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:492: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:493: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:493: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:494: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:527: error: ‘__var_CreateGetIntegerCommand’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:527: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:527: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:527: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:527: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:528: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:540: error: ‘__var_CreateGetBoolCommand’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:540: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:540: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:540: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:540: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:541: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:553: error: ‘__var_CreateGetTimeCommand’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:553: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:553: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:553: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:553: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:554: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:566: error: ‘__var_CreateGetFloatCommand’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:566: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:566: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:566: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:566: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:567: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:579: error: ‘__var_CreateGetStringCommand’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:579: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:579: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:580: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:580: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:581: error: expected ‘,’ or ‘;’ before ‘{’ token ../vlc-0.9.10/include/vlc_variables.h:587: error: ‘__var_CreateGetNonEmptyStringCommand’ declared as an ‘inline’ variable ../vlc-0.9.10/include/vlc_variables.h:587: error: ‘vlc_object_t’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:587: error: ‘p_obj’ was not declared in this scope ../vlc-0.9.10/include/vlc_variables.h:588: error: expected primary-expression before ‘const’ ../vlc-0.9.10/include/vlc_variables.h:588: error: initializer expression list treated as compound expression ../vlc-0.9.10/include/vlc_variables.h:589: error: expected ‘,’ or ‘;’ before ‘{’ token src/transcribeWidget.cpp:859: warning: unused parameter ‘bytesSent’ src/transcribeWidget.cpp:859: warning: unused parameter ‘bytesTotal’ ../vlc-0.9.10/include/vlc_variables.h:201: warning: ‘__var_SetInteger’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:215: warning: ‘__var_SetBool’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:229: warning: ‘__var_SetTime’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:243: warning: ‘__var_SetFloat’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:257: warning: ‘__var_SetString’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:270: warning: ‘__var_SetVoid’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:302: warning: ‘__var_GetInteger’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:317: warning: ‘__var_GetBool’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:332: warning: ‘__var_GetTime’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:347: warning: ‘__var_GetFloat’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:362: warning: ‘__var_GetString’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:371: warning: ‘__var_GetNonEmptyString’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:437: warning: ‘__var_CreateGetInteger’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:449: warning: ‘__var_CreateGetBool’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:461: warning: ‘__var_CreateGetTime’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:473: warning: ‘__var_CreateGetFloat’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:485: warning: ‘__var_CreateGetString’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:492: warning: ‘__var_CreateGetNonEmptyString’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:527: warning: ‘__var_CreateGetIntegerCommand’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:540: warning: ‘__var_CreateGetBoolCommand’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:553: warning: ‘__var_CreateGetTimeCommand’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:566: warning: ‘__var_CreateGetFloatCommand’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:579: warning: ‘__var_CreateGetStringCommand’ defined but not used ../vlc-0.9.10/include/vlc_variables.h:587: warning: ‘__var_CreateGetNonEmptyStringCommand’ defined but not used

    Read the article

  • Re: Help with Boost Grammar

    - by Decmac04
    I have redesigned and extended the grammar I asked about earlier as shown below: // BIFAnalyser.cpp : Defines the entry point for the console application. // // /*============================================================================= Copyright (c) Temitope Jos Onunkun 2010 http://www.dcs.kcl.ac.uk/pg/onun/ Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ //////////////////////////////////////////////////////////////////////////// // // // B Machine parser using the Boost "Grammar" and "Semantic Actions". // // // //////////////////////////////////////////////////////////////////////////// include include include include include include //////////////////////////////////////////////////////////////////////////// using namespace std; using namespace boost::spirit; //////////////////////////////////////////////////////////////////////////// // // Semantic Actions // //////////////////////////////////////////////////////////////////////////// // // namespace { //semantic action function on individual lexeme void do_noint(char const* start, char const* end) { string str(start, end); if (str != "NAT1") cout << "PUSH(" << str << ')' << endl; } //semantic action function on addition of lexemes void do_add(char const*, char const*) { cout << "ADD" << endl; // for(vector::iterator vi = strVect.begin(); vi < strVect.end(); ++vi) // cout << *vi << " "; } //semantic action function on subtraction of lexemes void do_subt(char const*, char const*) { cout << "SUBTRACT" << endl; } //semantic action function on multiplication of lexemes void do_mult(char const*, char const*) { cout << "\nMULTIPLY" << endl; } //semantic action function on division of lexemes void do_div(char const*, char const*) { cout << "\nDIVIDE" << endl; } // // vector flowTable; //semantic action function on simple substitution void do_sSubst(char const* start, char const* end) { string str(start, end); //use boost tokenizer to break down tokens typedef boost::tokenizer Tokenizer; boost::char_separator sep(" -+/*:=()",0,boost::drop_empty_tokens); // char separator definition Tokenizer tok(str, sep); Tokenizer::iterator tok_iter = tok.begin(); pair dependency; //create a pair object for dependencies //create a vector object to store all tokens vector dx; // int counter = 0; // tracks token position for(tok.begin(); tok_iter != tok.end(); ++tok_iter) //save all tokens in vector { dx.push_back(*tok_iter ); } counter = dx.size(); // vector d_hat; //stores set of dependency pairs string dep; //pairs variables as string object // dependency.first = *tok.begin(); vector FV; for(int unsigned i=1; i < dx.size(); i++) { // if(!atoi(dx.at(i).c_str()) && (dx.at(i) !=" ")) { dependency.second = dx.at(i); dep = dependency.first + "|-" + dependency.second + " "; d_hat.push_back(dep); vector<string> row; row.push_back(dependency.first); //push x_hat into first column of each row for(unsigned int j=0; j<2; j++) { row.push_back(dependency.second);//push an element (column) into the row } flowTable.push_back(row); //Add the row to the main vector } } //displays internal representation of information flow table cout << "\n****************\nDependency Table\n****************\n"; cout << "X_Hat\tDx\tG_Hat\n"; cout << "-----------------------------\n"; for(unsigned int i=0; i < flowTable.size(); i++) { for(unsigned int j=0; j<2; j++) { cout << flowTable[i][j] << "\t "; } if (*tok.begin() != "WHILE" ) //if there are no global flows, cout << "\t{}"; //display empty set cout << "\n"; } cout << "***************\n\n"; for(int unsigned j=0; j < FV.size(); j++) { if(FV.at(j) != dependency.second) dep = dependency.first + "|-" + dependency.second + " "; d_hat.push_back(dep); } cout << "PUSH(" << str << ')' << endl; cout << "\n*******\nDependency pairs\n*******\n"; for(int unsigned i=0; i < d_hat.size(); i++) cout << d_hat.at(i) << "\n...\n"; cout << "\nSIMPLE SUBSTITUTION\n\n"; } //semantic action function on multiple substitution void do_mSubst(char const* start, char const* end) { string str(start, end); cout << "PUSH(" << str << ')' << endl; //cout << "\nMULTIPLE SUBSTITUTION\n\n"; } //semantic action function on unbounded choice substitution void do_mChoice(char const* start, char const* end) { string str(start, end); cout << "PUSH(" << str << ')' << endl; cout << "\nUNBOUNDED CHOICE SUBSTITUTION\n\n"; } void do_logicExpr(char const* start, char const* end) { string str(start, end); //use boost tokenizer to break down tokens typedef boost::tokenizer Tokenizer; boost::char_separator sep(" -+/*=:()<",0,boost::drop_empty_tokens); // char separator definition Tokenizer tok(str, sep); Tokenizer::iterator tok_iter = tok.begin(); //pair dependency; //create a pair object for dependencies //create a vector object to store all tokens vector dx; for(tok.begin(); tok_iter != tok.end(); ++tok_iter) //save all tokens in vector { dx.push_back(*tok_iter ); } for(unsigned int i=0; i cout << "PUSH(" << str << ')' << endl; cout << "\nPREDICATE\n\n"; } void do_predicate(char const* start, char const* end) { string str(start, end); cout << "PUSH(" << str << ')' << endl; cout << "\nMULTIPLE PREDICATE\n\n"; } void do_ifSelectPre(char const* start, char const* end) { string str(start, end); //if cout << "PUSH(" << str << ')' << endl; cout << "\nPROTECTED SUBSTITUTION\n\n"; } //semantic action function on machine substitution void do_machSubst(char const* start, char const* end) { string str(start, end); cout << "PUSH(" << str << ')' << endl; cout << "\nMACHINE SUBSTITUTION\n\n"; } } //////////////////////////////////////////////////////////////////////////// // // Machine Substitution Grammar // //////////////////////////////////////////////////////////////////////////// // Simple substitution grammar parser with integer values removed struct Substitution : public grammar { template struct definition { definition(Substitution const& ) { machine_subst = ( (simple_subst) | (multi_subst) | (if_select_pre_subst) | (unbounded_choice) )[&do_machSubst] ; unbounded_choice = str_p("ANY") ide_list str_p("WHERE") predicate str_p("THEN") machine_subst str_p("END") ; if_select_pre_subst = ( ( str_p("IF") predicate str_p("THEN") machine_subst *( str_p("ELSIF") predicate machine_subst ) !( str_p("ELSE") machine_subst) str_p("END") ) | ( str_p("SELECT") predicate str_p("THEN") machine_subst *( str_p("WHEN") predicate machine_subst ) !( str_p("ELSE") machine_subst) str_p("END")) | ( str_p("PRE") predicate str_p("THEN") machine_subst str_p("END") ) )[&do_ifSelectPre] ; multi_subst = ( (machine_subst) *( ( str_p("||") (machine_subst) ) | ( str_p("[]") (machine_subst) ) ) ) [&do_mSubst] ; simple_subst = (identifier str_p(":=") arith_expr) [&do_sSubst] ; expression = predicate | arith_expr ; predicate = ( (logic_expr) *( ( ch_p('&') (logic_expr) ) | ( str_p("OR") (logic_expr) ) ) )[&do_predicate] ; logic_expr = ( identifier (str_p("<") arith_expr) | (str_p("<") arith_expr) | (str_p("/:") arith_expr) | (str_p("<:") arith_expr) | (str_p("/<:") arith_expr) | (str_p("<<:") arith_expr) | (str_p("/<<:") arith_expr) | (str_p("<=") arith_expr) | (str_p("=") arith_expr) | (str_p("=") arith_expr) | (str_p("=") arith_expr) ) [&do_logicExpr] ; arith_expr = term *( ('+' term)[&do_add] | ('-' term)[&do_subt] ) ; term = factor ( ('' factor)[&do_mult] | ('/' factor)[&do_div] ) ; factor = lexeme_d[( identifier | +digit_p)[&do_noint]] | '(' expression ')' | ('+' factor) ; ide_list = identifier *( ch_p(',') identifier ) ; identifier = alpha_p +( alnum_p | ch_p('_') ) ; } rule machine_subst, unbounded_choice, if_select_pre_subst, multi_subst, simple_subst, expression, predicate, logic_expr, arith_expr, term, factor, ide_list, identifier; rule<ScannerT> const& start() const { return predicate; //return multi_subst; //return machine_subst; } }; }; //////////////////////////////////////////////////////////////////////////// // // Main program // //////////////////////////////////////////////////////////////////////////// int main() { cout << "*********************************\n\n"; cout << "\t\t...Machine Parser...\n\n"; cout << "*********************************\n\n"; // cout << "Type an expression...or [q or Q] to quit\n\n"; string str; int machineCount = 0; char strFilename[256]; //file name store as a string object do { cout << "Please enter a filename...or [q or Q] to quit:\n\n "; //prompt for file name to be input //char strFilename[256]; //file name store as a string object cin strFilename; if(*strFilename == 'q' || *strFilename == 'Q') //termination condition return 0; ifstream inFile(strFilename); // opens file object for reading //output file for truncated machine (operations only) if (inFile.fail()) cerr << "\nUnable to open file for reading.\n" << endl; inFile.unsetf(std::ios::skipws); Substitution elementary_subst; // Simple substitution parser object string next; while (inFile str) { getline(inFile, next); str += next; if (str.empty() || str[0] == 'q' || str[0] == 'Q') break; parse_info< info = parse(str.c_str(), elementary_subst !end_p, space_p); if (info.full) { cout << "\n-------------------------\n"; cout << "Parsing succeeded\n"; cout << "\n-------------------------\n"; } else { cout << "\n-------------------------\n"; cout << "Parsing failed\n"; cout << "stopped at: " << info.stop << "\"\n"; cout << "\n-------------------------\n"; } } } while ( (*strFilename != 'q' || *strFilename !='Q')); return 0; } However, I am experiencing the following unexpected behaviours on testing: The text files I used are: f1.txt, ... containing ...: debt:=(LoanRequest+outstandingLoan1)*20 . f2.txt, ... containing ...: debt:=(LoanRequest+outstandingLoan1)*20 || newDebt := loanammount-paidammount || price := purchasePrice + overhead + bb . f3.txt, ... containing ...: yy < (xx+7+ww) . f4.txt, ... containing ...: yy < (xx+7+ww) & yy : NAT . When I use multi_subst as start rule both files (f1 and f2) are parsed correctly; When I use machine_subst as start rule file f1 parse correctly, while file f2 fails, producing the error: “Parsing failed stopped at: || newDebt := loanammount-paidammount || price := purchasePrice + overhead + bb” When I use predicate as start symbol, file f3 parse correctly, but file f4 yields the error: “ “Parsing failed stopped at: & yy : NAT” Can anyone help with the grammar, please? It appears there are problems with the grammar that I have so far been unable to spot.

    Read the article

  • Error codes for C++

    - by billy
    #include <iostream> #include <iomanip> using namespace std; //Global constant variable declaration const int MaxRows = 8, MaxCols = 10, SEED = 10325; //Functions Declaration void PrintNameHeader(ostream& out); void Fill2DArray(double ary[][MaxCols]); void Print2DArray(const double ary[][MaxCols]); double GetTotal(const double ary[][MaxCols]); double GetAverage(const double ary[][MaxCols]); double GetRowTotal(const double ary[][MaxCols], int theRow); double GetColumnTotal(const double ary[][MaxCols], int theRow); double GetHighestInRow(const double ary[][MaxCols], int theRow); double GetLowestInRow(const double ary[][MaxCols], int theRow); double GetHighestInCol(const double ary[][MaxCols], int theCol); double GetLowestInCol(const double ary[][MaxCols], int theCol); double GetHighest(const double ary[][MaxCols], int& theRow, int& theCol); double GetLowest(const double ary[][MaxCols], int& theRow, int& theCol); int main() { int theRow; int theCol; PrintNameHeader(cout); cout << fixed << showpoint << setprecision(1); srand(static_cast<unsigned int>(SEED)); double ary[MaxRows][MaxCols]; cout << "The seed value for random number generator is: " << SEED << endl; cout << endl; Fill2DArray(ary); Print2DArray(ary); cout << " The Total for all the elements in this array is: " << setw(7) << GetTotal(ary) << endl; cout << "The Average of all the elements in this array is: " << setw(7) << GetAverage(ary) << endl; cout << endl; cout << "The sum of each row is:" << endl; for(int index = 0; index < MaxRows; index++) { cout << "Row " << (index + 1) << ": " << GetRowTotal(ary, theRow) << endl; } cout << "The highest and lowest of each row is: " << endl; for(int index = 0; index < MaxCols; index++) { cout << "Row " << (index + 1) << ": " << GetHighestInRow(ary, theRow) << " " << GetLowestInRow(ary, theRow) << endl; } cout << "The highest and lowest of each column is: " << endl; for(int index = 0; index < MaxCols; index++) { cout << "Col " << (index + 1) << ": " << GetHighestInCol(ary, theRow) << " " << GetLowestInCol(ary, theRow) << endl; } cout << "The highest value in all the elements in this array is: " << endl; cout << GetHighest(ary, theRow, theCol) << "[" << theRow << "]" << "[" << theCol << "]" << endl; cout << "The lowest value in all the elements in this array is: " << endl; cout << GetLowest(ary, theRow, theCol) << "[" << theRow << "]" << "[" << theCol << "]" << endl; return 0; } //Define Functions void PrintNameHeader(ostream& out) { out << "*******************************" << endl; out << "* *" << endl; out << "* C.S M10A Spring 2010 *" << endl; out << "* Programming Assignment 10 *" << endl; out << "* Due Date: Thurs. Mar. 25 *" << endl; out << "*******************************" << endl; out << endl; } void Fill2DArray(double ary[][MaxCols]) { for(int index1 = 0; index1 < MaxRows; index1++) { for(int index2= 0; index2 < MaxCols; index2++) { ary[index1][index2] = (rand()%1000)/10; } } } void Print2DArray(const double ary[][MaxCols]) { cout << " Column "; for(int index = 0; index < MaxCols; index++) { int column = index + 1; cout << " " << column << " "; } cout << endl; cout << " "; for(int index = 0; index < MaxCols; index++) { int column = index +1; cout << "----- "; } cout << endl; for(int index1 = 0; index1 < MaxRows; index1++) { cout << "Row " << (index1 + 1) << ":"; for(int index2= 0; index2 < MaxCols; index2++) { cout << setw(6) << ary[index1][index2]; } } } double GetTotal(const double ary[][MaxCols]) { double total = 0; for(int theRow = 0; theRow < MaxRows; theRow++) { total = total + GetRowTotal(ary, theRow); } return total; } double GetAverage(const double ary[][MaxCols]) { double total = 0, average = 0; total = GetTotal(ary); average = total / (MaxRows * MaxCols); return average; } double GetRowTotal(const double ary[][MaxCols], int theRow) { double sum = 0; for(int index = 0; index < MaxCols; index++) { sum = sum + ary[theRow][index]; } return sum; } double GetColumTotal(const double ary[][MaxCols], int theCol) { double sum = 0; for(int index = 0; index < theCol; index++) { sum = sum + ary[index][theCol]; } return sum; } double GetHighestInRow(const double ary[][MaxCols], int theRow) { double highest = 0; for(int index = 0; index < MaxCols; index++) { if(ary[theRow][index] > highest) highest = ary[theRow][index]; } return highest; } double GetLowestInRow(const double ary[][MaxCols], int theRow) { double lowest = 0; for(int index = 0; index < MaxCols; index++) { if(ary[theRow][index] < lowest) lowest = ary[theRow][index]; } return lowest; } double GetHighestInCol(const double ary[][MaxCols], int theCol) { double highest = 0; for(int index = 0; index < MaxRows; index++) { if(ary[index][theCol] > highest) highest = ary[index][theCol]; } return highest; } double GetLowestInCol(const double ary[][MaxCols], int theCol) { double lowest = 0; for(int index = 0; index < MaxRows; index++) { if(ary[index][theCol] < lowest) lowest = ary[index][theCol]; } return lowest; } double GetHighest(const double ary[][MaxCols], int& theRow, int& theCol) { theRow = 0; theCol = 0; double highest = ary[theRow][theCol]; for(int index = 0; index < MaxRows; index++) { for(int index1 = 0; index1 < MaxCols; index1++) { double highest = 0; if(ary[index1][theCol] > highest) { highest = ary[index][index1]; theRow = index; theCol = index1; } } } return highest; } double Getlowest(const double ary[][MaxCols], int& theRow, int& theCol) { theRow = 0; theCol = 0; double lowest = ary[theRow][theCol]; for(int index = 0; index < MaxRows; index++) { for(int index1 = 0; index1 < MaxCols; index1++) { double lowest = 0; if(ary[index1][theCol] < lowest) { lowest = ary[index][index1]; theRow = index; theCol = index1; } } } return lowest; } . 1>------ Build started: Project: teddy lab 10, Configuration: Debug Win32 ------ 1>Compiling... 1>lab 10.cpp 1>c:\users\owner\documents\visual studio 2008\projects\teddy lab 10\teddy lab 10\ lab 10.cpp(46) : warning C4700: uninitialized local variable 'theRow' used 1>c:\users\owner\documents\visual studio 2008\projects\teddy lab 10\teddy lab 10\ lab 10.cpp(62) : warning C4700: uninitialized local variable 'theCol' used 1>Linking... 1> lab 10.obj : error LNK2028: unresolved token (0A0002E0) "double __cdecl GetLowest(double const (* const)[10],int &,int &)" (?GetLowest@@$$FYANQAY09$$CBNAAH1@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1> lab 10.obj : error LNK2019: unresolved external symbol "double __cdecl GetLowest(double const (* const)[10],int &,int &)" (?GetLowest@@$$FYANQAY09$$CBNAAH1@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>C:\Users\owner\Documents\Visual Studio 2008\Projects\ lab 10\Debug\ lab 10.exe : fatal error LNK1120: 2 unresolved externals 1>Build log was saved at "file://c:\Users\owner\Documents\Visual Studio 2008\Projects\ lab 10\teddy lab 10\Debug\BuildLog.htm" 1>teddy lab 10 - 3 error(s), 2 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Read the article

  • Alright, I'm still stuck on this homework problem. C++

    - by Josh
    Okay, the past few days I have been trying to get some input on my programs. Well I decided to scrap them for the most part and try again. So once again, I'm in need of help. For the first program I'm trying to fix, it needs to show the sum of SEVEN numbers. Well, I'm trying to change is so that I don't need the mem[##] = ####. I just want the user to be able to input the numbers and the program run from there and go through my switch loop. And have some kind of display..saying like the sum is?.. Here's my code so far. #include <iostream> #include <iomanip> #include <ios> using namespace std; int main() { const int READ = 10; const int WRITE = 11; const int LOAD = 20; const int STORE = 21; const int ADD = 30; const int SUBTRACT = 31; const int DIVIDE = 32; const int MULTIPLY = 33; const int BRANCH = 40; const int BRANCHNEG = 41; const int BRANCHZERO = 42; const int HALT = 43; int mem[100] = {0}; //Making it 100, since simpletron contains a 100 word mem. int operation; //taking the rest of these variables straight out of the book seeing as how they were italisized. int operand; int accum = 0; // the special register is starting at 0 int counter; for ( counter=0; counter < 100; counter++) mem[counter] = 0; // This is for part a, it will take in positive variables in //a sent-controlled loop and compute + print their sum. Variables from example in text. mem[0] = 1009; mem[1] = 1109; mem[2] = 2010; mem[3] = 2111; mem[4] = 2011; mem[5] = 3100; mem[6] = 2113; mem[7] = 1113; mem[8] = 4300; counter = 0; //Makes the variable counter start at 0. while(true) { operand = mem[ counter ]%100; // Finds the op codes from the limit on the mem (100) operation = mem[ counter ]/100; //using a switch loop to set up the loops for the cases switch ( operation ){ case READ: //reads a variable into a word from loc. Enter in -1 to exit cout <<"\n Input a positive variable: "; cin >> mem[ operand ]; counter++; break; case WRITE: // takes a word from location cout << "\n\nThe content at location " << operand << " is " << mem[operand]; counter++; break; case LOAD:// loads accum = mem[ operand ];counter++; break; case STORE: //stores mem[ operand ] = accum;counter++; break; case ADD: //adds accum += mem[operand];counter++; break; case SUBTRACT: // subtracts accum-= mem[ operand ];counter++; break; case DIVIDE: //divides accum /=(mem[ operand ]);counter++; break; case MULTIPLY: // multiplies accum*= mem [ operand ];counter++; break; case BRANCH: // Branches to location counter = operand; break; case BRANCHNEG: //branches if acc. is < 0 if (accum < 0) counter = operand; else counter++; break; case BRANCHZERO: //branches if acc = 0 if (accum == 0) counter = operand; else counter++; break; case HALT: // Program ends break; } } return 0; } part B int main() { const int READ = 10; const int WRITE = 11; const int LOAD = 20; const int STORE = 21; const int ADD = 30; const int SUBTRACT = 31; const int DIVIDE = 32; const int MULTIPLY = 33; const int BRANCH = 40; const int BRANCHNEG = 41; const int BRANCHZERO = 41; const int HALT = 43; int mem[100] = {0}; int operation; int operand; int accum = 0; int pos = 0; int j; mem[22] = 7; // loop 7 times mem[25] = 1; // increment by 1 mem[00] = 4306; mem[01] = 2303; mem[02] = 3402; mem[03] = 6410; mem[04] = 3412; mem[05] = 2111; mem[06] = 2002; mem[07] = 2312; mem[08] = 4210; mem[09] = 2109; mem[10] = 4001; mem[11] = 2015; mem[12] = 3212; mem[13] = 2116; mem[14] = 1101; mem[15] = 1116; mem[16] = 4300; j = 0; while ( true ) { operand = memory[ j ]%100; // Finds the op codes from the limit on the memory (100) operation = memory[ j ]/100; //using a switch loop to set up the loops for the cases switch ( operation ){ case 1: //reads a variable into a word from loc. Enter in -1 to exit cout <<"\n enter #: "; cin >> memory[ operand ]; break; case 2: // takes a word from location cout << "\n\nThe content at location " << operand << "is " << memory[operand]; break; case 3:// loads accum = memory[ operand ]; break; case 4: //stores memory[ operand ] = accum; break; case 5: //adds accum += mem[operand];; break; case 6: // subtracts accum-= memory[ operand ]; break; case 7: //divides accum /=(memory[ operand ]); break; case 8: // multiplies accum*= memory [ operand ]; break; case 9: // Branches to location j = operand; break; case 10: //branches if acc. is < 0 break; case 11: //branches if acc = 0 if (accum == 0) j = operand; break; case 12: // Program ends exit(0); break; } j++; } return 0; }

    Read the article

  • How do I mock a method with an open array parameter in PascalMock?

    - by Oliver Giesen
    I'm currently in the process of getting started with unit testing and mocking for good and I stumbled over the following method that I can't seem to fabricate a working mock implementation for: function GetInstance(const AIID: TGUID; out AInstance; const AArgs: array of const; const AContextID: TImplContextID = CID_DEFAULT): Boolean; (TImplContextID is just an alias for Integer) I thought it would have to look something like this: function TImplementationProviderMock.GetInstance( const AIID: TGUID; out AInstance; const AArgs: array of const; const AContextID: TImplContextID): Boolean; begin Result := AddCall('GetInstance') .WithParams([@AIID, AContextID]) .ReturnsOutParams([AInstance]) .ReturnValue; end; But the compiler complains about the .ReturnsOutParams([AInstance]) saying "Bad argument type in variable type array constructor.". Also I haven't found a way to specify the open array parameter AArgs at all. Also, is using the @-notation for the TGUID-typed parameter the right way to go? Is it possible to mock this method with the current version of PascalMock at all? Update: I now realize I got the purpose of ReturnsOutParams completely wrong: It's intended to be used for populating the values to be returned when defining the expectations rather than for mocking the call itself. I now think the correct syntax for mocking the out parameter would probably have to look more like this: function TImplementationProviderMock.GetInstance( const AIID: TGUID; out AInstance; const AArgs: array of const; const AContextID: TImplContextID): Boolean; var lCall: TMockMethod; begin lCall := AddCall('GetInstance').WithParams([@AIID, AContextID]); Pointer(AInstance) := lCall.OutParams[0]; Result := lCall.ReturnValue; end; The questions that remain are how to mock the open array parameter AArgs and whether passing the TGUID argument (i.e. a value type) by address will work out...

    Read the article

  • Using proxy models

    - by smallB
    I've created Proxy model by subclassing QAbstractProxyModel and connected it as a model to my view. I also set up source model for this proxy model. Unfortunately something is wrong because I'm not getting anything displayed on my listView (it works perfectly when I have my model supplied as a model to view but when I supply this proxy model it just doesn't work). Here are some snippets from my code: #ifndef FILES_PROXY_MODEL_H #define FILES_PROXY_MODEL_H #include <QAbstractProxyModel> #include "File_List_Model.h" class File_Proxy_Model: public QAbstractProxyModel { public: explicit File_Proxy_Model(File_List_Model* source_model) { setSourceModel(source_model); } virtual QModelIndex mapFromSource(const QModelIndex & sourceIndex) const { return index(sourceIndex.row(),sourceIndex.column()); } virtual QModelIndex mapToSource(const QModelIndex & proxyIndex) const { return index(proxyIndex.row(),proxyIndex.column()); } virtual int columnCount(const QModelIndex & parent = QModelIndex()) const { return sourceModel()->columnCount(); } virtual int rowCount(const QModelIndex & parent = QModelIndex()) const { return sourceModel()->rowCount(); } virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const { return createIndex(row,column); } virtual QModelIndex parent(const QModelIndex & index) const { return QModelIndex(); } }; #endif // FILES_PROXY_MODEL_H //and this is a dialog class: Line_Counter::Line_Counter(QWidget *parent) : QDialog(parent), model_(new File_List_Model(this)), proxy_model_(new File_Proxy_Model(model_)), sel_model_(new QItemSelectionModel(proxy_model_,this)) { setupUi(this); setup_mvc_(); } void Line_Counter::setup_mvc_() { listView->setModel(proxy_model_); listView->setSelectionModel(sel_model_); }

    Read the article

  • C++ overloading comparative operators for a MyString class

    - by Taylor Gang
    bool operator == (const MyString& left, const MyString& right) { if(left.value == right.value) return true; else return false; } bool operator != (const MyString& left, const MyString& right) { if(left == right) return false; else return true; } bool operator < (const MyString& left, const MyString& right) { if(strcmp(left.value, right.value) == -1) return true; else return false; } bool operator > (const MyString& left, const MyString& right) { if(strcmp(left.value, right.value) == 1) return true; else return false; } bool operator <= (const MyString& left, const MyString& right) { if(strcmp(left.value, right.value) == -1 || strcmp(left.value, right.value) == 0) return true; else return false; } bool operator >= (const MyString& left, const MyString& right) { if(strcmp(left.value, right.value) == 1 || strcmp(left.value, right.value) == 0) return true; else return false; } So these are my implemented comparison operators for my MyString class, they fail the test program that my professor gave me and could use some direction. Thanks in advance for any and all help I receive.

    Read the article

  • C++ Directx 11 D3DXVec3Unproject

    - by Miguel P
    Hello dear people from the underworld called the internet. So guys, Im having a small issue with D3DXVec3Unproject, because I'm currently using Directx 11 and not 10, and the requirements for this function is: D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3D10_VIEWPORT *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld As you may have noticed, it requires a D3D10_VIEWPORT, and I'm using a Directx 11 viewport, D3D11_VIEWPORT. So do you have any ideas how i can use D3DXVec3Unproject with Directx 11? Thank You

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >