C++ :: Errors About Types - Ambiguous Call
Nov 6, 2013
Code:
void write() {
setlocale(LC_ALL, "en_US.UTF-8");
cout <<"";
}
template <typename A, typename ...B>
void write(string argHead, B... argTail) {
setlocale(LC_ALL, "en_US.UTF-8");
[Code] ....
what I'm doing wrong with my write() function? I did like the read() function(for work diferent with another types) but i get these error:
"C:UsersJoaquimDocumentsCodeBlocksMy Classconsole.h|218|error: call of overloaded 'to_string(char*&)' is ambiguous|"
View 14 Replies
ADVERTISEMENT
Dec 4, 2013
I need to make a stub for some standard library function, but the compiler gets confused about which function I want to call in my code. I thought that putting the stubbed function together with its caller into an anonymous namespace will give higher precedence to the stub, but it didn't.
Here is an example code:
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <signal.h>
namespace{
int sigaction(int signum, const struct sigaction * act, struct sigaction * oldact)
[Code] ....
Result:
main.cpp: In function ‘void {anonymous}::test()’:
main.cpp:23:47: error: call of overloaded ‘sigaction(int, sigaction*, NULL)’ is ambiguous
main.cpp:23:47: note: candidates are:
main.cpp:8:5: note: int {anonymous}::sigaction(int, const sigaction*, sigaction*)
In file included from main.cpp:4:0:
/usr/include/signal.h:266:12: note: int sigaction(int, const sigaction*, sigaction*)
It possible to force the compiler to use my stubbed version of sigaction() and if yes, how to do that? I am not allowed to modify test() function.
View 4 Replies
View Related
Oct 30, 2013
When compiling the code
#include "tensor.h"
int main() {
Tensor<2,-2> m = {{1,2},{1,3}};
Tensor<2> v = {1,5};
std::cout<<m*v<<"
[Code] ....
Why do I get an ambiguity and why is not the wanted operator*-overload (the last one in the tensor.h file) not even mentioned as one of the candidates? Is it clear what I want to do? And if so, what can I do to make the call unambiguous?
View 3 Replies
View Related
Oct 23, 2013
I am writing a program in C. The following is an extract from my code:
Code:
enum coin_types{
FIVE_CENTS=5,
TEN_CENTS=10,
TWENTY_CENTS=20,
FIFTY_CENTS=50,
ONE_DOLLAR=100,
TWO_DOLLARS=200
[Code] .....
I'm getting the following errors:
For: new = new_coins_data_line(line);
"Incompatible types in assignment"
For: return newdata;
"Incompatible types in return"
There seem to be problems with my variables and perhaps it is related to the type 'struct coin' which has an enumerated type within it.
View 5 Replies
View Related
Feb 23, 2014
I get the following error in XCode whenever I try to access the member I created 'randomGen' in a separate class in a different header file. I have made sure to include the header file and have tried to access it through an object.
This is the code I enter when trying to access the method from randomiser.h in main.cpp. It is also an overloaded function with doubles and integers:
RandomG randomiser;
randomiser.randomGen(); // 'Call to member function 'randomGen' is ambiguous'
This is the code inside randomiser.h:
#include <string>
#include <iostream>
using std::string;
using std::cout;
using std::endl;
class RandomG {
[Code] ....
This is the error inside xcode: [URL] ....
I have tried seperating the code for the functions in another class (main.cpp) and then running and it seems to works, so I'm not sure why I can't put everything in the .h file and then access it?
I would like it in a seperate file so it doesn't clutter my main. I am writing a game with SDL so that might be confusing and I would like the window to have a random title and other random properties, so it would be easier to use a function.
View 3 Replies
View Related
Oct 22, 2013
My load function isnt working. I've tested it and returned it as an int and it worked but when i tried to compile when i changed it to a template i started getting the errors and I'm not sure how to fix it:
all_sort.cpp:41:15: error: no matching function for call to 'load'
int *value = load("./integers.txt", size);
^~~~
./bubble_sort.h:44:4: note: candidate template ignored: couldn't infer template
argument 'T'
T *load(const char* x, int &size) {
[Code] ....
I'm trying to use my load function to load integers from a file into and array and then return it back.
#include "bubble_sort.h"
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int main(){
int n, pick = 1, size = 0;
[Code] ....
View 1 Replies
View Related
Jan 22, 2014
I have this
Code:
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int check_up(char string[]);
int check_low(char string[]);
void to_up(char string[]);
void to_low(char string[]);
[Code] .....
When I compile this I have the following problems: warning: data definition has no type or storage class [enabled by default] in 'to_up(word)'conflicting types in 'to_up' function and to_low function warning: data definition has no type or storage class [enabled by default] into_up function error: unknown type name "word" in line 'printf("All uppercase %s. ", word):;'warning: parameter names (without types) in function declaration [enabled by default] in 'to_up(word)'and 'to_low(word)' 'note: previous declaration of "to_up" was here in function declaration of to_up function
View 7 Replies
View Related
Feb 18, 2014
I'm using GCC 4.8.1 and I want to implement a XML parser using TinyXML and port it to AngelScript
Now, it says: reference to 'Column' is ambiguous
I've declared a class called xml_parser and I've added everything of tinyxml as it's public member when I call Column(), and also Row(), it give's this error. what should I do?
This is it's code:
xml_parser.hpp:
#ifndef AGK_XML_PARSER_H
#define AGK_XML_PARSER_H
#define TIXML_USE_STL
#include <tinyxml.h>
[Code] .....
View 16 Replies
View Related
Feb 9, 2014
Okay so inside my ArcherArmor.cpp, I'm trying to figure out why the map initializer list isn't working, but for some reason I keep getting "Error C2593: 'operator =' is ambiguous". Here is my code:
I also have a class which ArcherArmor is derived from, that has a struct called `Armor`, which I left out for simplicity. The main problem is that error! The only thing I can think of is that im initializing the map wrong.
//ArcherArmor.h
#include <string>
#include <map>
class ArcherArmor {
private:
map <int, Armor> soldier_armor;
public:
void ArcherArmor_shop();
[Code] .....
View 7 Replies
View Related
May 28, 2013
Here is the error I am getting:
1>d: estprojectgdiplusrenderer.h(61): error C2872: 'Font' : ambiguous symbol
1> could be 'c:program files (x86)microsoft visual studio 10.0vcincludecomdef.h(312) : Font'
1> or 'c:program files (x86)microsoft sdkswindowsv7.0aincludegdiplusheaders.h(244) : Gdiplus::Font'
How can I fix this issue?
View 2 Replies
View Related
May 4, 2013
The compiler keeps on telling me that invalid conversion from wxBitmap* to wxString on the line with the AddTool function, whiles I do not even try to do such an ambiguous typecast.
wxWidgets 2.9.4
MinGW
gdb
Code:
#include "mainwnd.h"
//namespaces
//other definitions and declarations
CMAINWND::CMAINWND(const wxString& szTitle):wxFrame(NULL,wxID_ANY,szTitle) {
wxImage::AddHandler(new wxBMPHandler);
[Code] .....
View 8 Replies
View Related
Jan 15, 2014
Let's say I have a templated base class:
Code:
template <typename Input>
class Consumer
{
public:
void consume(Input input)
{
// do something
}
};
Now, I have a class which derives from this twice (A and B are unrelated, but otherwise unimportant classes):
Code:
class A;
class B;
class Derived: public Consumer<A>, public Consumer<B>
{
};
Now, elsewhere in the code I do this:
Code:
{
A myA;
Derived myDerived;
myDerived.consume(myA);
}
This looks like it should be simple enough, but g++ 4.8.1 is giving me a "request for member is ambiguous" error.
View 2 Replies
View Related
Jan 10, 2014
I am working on my project of gesture recognition using c++ and open cv and i am also designing GUI simultaneously. I am using system namespace for GUI part and cv namespace for gestures.
After compiling i am getting error as Ambiguous symbol String is used.
This the link for msdn error support : [URL] .....
View 5 Replies
View Related
Mar 1, 2014
i am writing this bank accounts program using structures. i haven't implemented the function before that i want to check if the data is being read and printed. When i build and run the program in visual studio it gives me the following error. "No constructor could take the source type, or constructor overload resolution was ambiguous". Now whats wrong in this program?
/* Bank Accounts Program */
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>//needed to use system() function
using namespace std;
const int MAX_NUM = 50;
struct Name{
[code]....
View 1 Replies
View Related
Apr 25, 2014
What is Function call Overhead and Function Call Stack?
View 2 Replies
View Related
Mar 25, 2014
identify the reason why I am getting a seg fault run error? I hate to bother but I've been trying for several days now to fix the same function.
class adjacencyList {
public:
explicit adjacencyList(int size);
void buildGraph(Edge inEdge);
void print();
[code].....
View 6 Replies
View Related
Sep 8, 2013
have several linux header files included and when I compile my program I get the below errors..Am I NOT supposed to use some of these headers? Source is below as well.Looking through the headers mentioned in these errors, it's looking like stuff really is defined in multiple places...
Code:
codeblox@Lubuntu-pc:~/Programming/C/Network/MITM/src$ gcc -g -o mitm *.c
In file included from mitm.h:12:0,
from create_raw.c:1:
/usr/include/netpacket/packet.h:22:8: error: redefinition of ‘struct sockaddr_ll’
In file included from /usr/include/linux/netdevice.h:30:0,
from /usr/include/linux/if_arp.h:26,
from mitm.h:10,
from create_raw.c:1:
}
[code]....
View 5 Replies
View Related
Feb 17, 2013
I've included <cstddef> into a project of mine in favour of <stddef.h>. When I tried to compile my project, I get 50+ errors stating that types such as "::size_t", "::div_t" and "::abort( )" have not been declared even though <cstddef> includes <stddef.h>.
I've tried searching both the global namespace and the standard namespace, but neither way works. At this moment in time, I don't have any compiler options enabled that may affect the way identifiers are defined, C++11 isn't enabled (which doesn't affect the <cstddef> header anyway), the project is a C++ project, and I've tried using the plain old <stddef.h> header, but the problems still persist.
I'm using GNU's C++ compiler ("__GNUG__" is defined).
View 3 Replies
View Related
Feb 15, 2013
I am new to C++ language and I am still learning.I'm doing basic stuff to better understand dynamic memory. I was wondering why I keep getting memory issues.*/
#define SIZE 15
class word {
char* str;
public:
[code]....
View 1 Replies
View Related
Dec 31, 2014
At this stage I will obtain Dimensions A, B & C. But after this before I do the pythagoras equation using the data I want it checked over. I think I've done this here but I'm not sure. I want it to report the message "Invalid Data" if Dimension A is not the longest.
cout << "Enter Dimension A:-";
cin >> DimA;
cout << "Enter Dimension B:-";
cin >> DimB;
cout << "Enter Dimension C:-";
cin >> DimC;
if (DimA >= DimB, DimC)
cout << endl << "Invalid Data";
View 15 Replies
View Related
Mar 22, 2014
# include <iostream>
# include <cstring>
#include <iomanip>
#include <cmath>
using namespace std;
class Course
// Creating the class Course
[Code] ....
Errors: Warning1warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
[Code] .....
I have to create an Array of type Course and then fill its member dats using various member functions. Those errors are caused by some Constructor defect, which I dont really know what it is.
View 2 Replies
View Related
Feb 1, 2015
I am currently just trying to update a record in a SQL database.I can add a record and delete a record just fine but when I go to update I get no errors but it just doesn't update.
Here is what I have and done coding for hours trial and error
private void btnAddProd_Click(object sender, RoutedEventArgs e)
{//validate method // product = new Product(txtProductName.Text, Convert.ToDecimal(txtProductCost.Text), txtProductType.Text);
product = new Product();
MakeProduct(product);
if(modify) {
Product theOneAndOnly = new Product();
[Code] ....
View 1 Replies
View Related
Mar 21, 2014
I'm currently messing around with geolocation and have this Windows App I'm working on. There is no errors or warnings when I run it, but it does not work. I click my Enable GPS button and nada, nothing, zilch. This isn't a important project or anything just a learning experience for myself.
This is my C# portion if you need me to post the XAML side also I can do that as well.
using System;
using System.Collections.Generic;
using System.IO;
[Code].....
View 5 Replies
View Related
Dec 17, 2014
i use cygwin and i have a program that was returning an error saying "undefined reference" and i figured out that i misspelled a word. how can i search for the misspelling in the input mode, if ive just completed a very large program and dont want to scroll through possibly 300+ lines of input? im not totally out the loop, but i know i can "vim program.cpp" to open the program, but before clicking "i" to actually edit, there must be a way to search a word
View 9 Replies
View Related
Sep 7, 2012
I am forced to have the deceleration of a class template in the .h file.
See here: [URL] ....
This works perfectly fine, as long as i #inlcude the header file only in ONE .cpp file.
The moment i #inlude it in several .cpp files, i get LNK2005 already-defined errors.
a.obj : error LNK2005: "public: unsigned int * __thiscall theclass::themthod(void)" (?xxx@theclass@@QAEPAIXZ) already defined in b.obj
I would have assumed inclusion guards can protect me from this, but wrong.
View 2 Replies
View Related
Dec 12, 2014
int* count;
count = new int(1); // what???
Is this on the heap?? do i have to delete it now?
So is 'new' on a primitive data type just a way for me to allocate primitive data types (int, char, etc.) on the heap instead of the stack?
And, out of curiosity, can you do that in Java?
View 4 Replies
View Related