473,666 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

compile error " instantiated from here"

Hi,
I have the following compile error instantiated from here, I appreciate
if someone can help me find out why?
g++ -O0 -g3 -Wall -c -fmessage-length=0 -ostddev.o ../stddev.cpp
.../stddev.cpp: In member function 'int
StatUtils::std_ dev(std::vector <int, std::allocator< int> >&, int,
int)':
.../stddev.cpp:206: warning: converting to 'int' from 'double'
.../stddev.cpp:215: warning: converting to 'int' from 'double'
.../stddev.cpp:218: warning: converting to 'int' from 'double'
.../stddev.cpp: In member function 'int
StatUtils::mean (std::vector<in t, std::allocator< int> >&, int, int)':
.../stddev.cpp:232: warning: converting to 'int' from 'double'
/usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/bits/stl_numeric.h:
In function '_Tp std::accumulate (_InputIterator , _InputIterator, _Tp,
_BinaryOperatio n) [with _InputIterator =
__gnu_cxx::__no rmal_iterator<i nt*, std::vector<int , std::allocator< int>
, _Tp = double, _BinaryOperatio n = do_std_dev<int>]':

.../stddev.cpp:215: instantiated from here
Here is the code :
template< class T1> class do_std_dev : public binary_function <T1, T1,
T1>
{
public:
do_std_dev(T1 mean): _mean(mean) { }

T1 operator() (T1 initial, T1 element) {
T1 x = element - _mean;
initial = initial + (x * x);
return initial;
}
private:
T1 _mean;
};

int StatUtils::std_ dev( vector<int>& v, int start, int end)
{
int stdDev = 0.0;
int mean2 = mean(v, start, end);
vector<int>::it erator startIter = v.begin();
vector<int>::it erator endIter = v.begin();

startIter += start;
endIter += end;

// this is line 215 of stddev.cpp:
int stdDevSum = accumulate (startIter, endIter, 0.0,
do_std_dev<int> (mean2));

return stdDevSum;
}

Feb 13 '06 #1
2 8972
> [...]
../stddev.cpp:215: warning: converting to 'int' from 'double'
[...]


I recommend you provide a complete minimal example without any
conversion-from-int-to-double-issue. Focus e.g. on int first. As far
as I see the conversion is of no relevance for the
standard-deviation-feature you want to have. Maybe clearing the
conversion-issue already leads to a working program.

Feb 13 '06 #2
In article <11************ **********@g14g 2000cwa.googleg roups.com>,
ke*********@gma il.com wrote:
Hi,
I have the following compile error instantiated from here, I appreciate
if someone can help me find out why?
g++ -O0 -g3 -Wall -c -fmessage-length=0 -ostddev.o ../stddev.cpp
../stddev.cpp: In member function 'int
StatUtils::std_ dev(std::vector <int, std::allocator< int> >&, int,
int)':
../stddev.cpp:206: warning: converting to 'int' from 'double'
../stddev.cpp:215: warning: converting to 'int' from 'double'
../stddev.cpp:218: warning: converting to 'int' from 'double'
../stddev.cpp: In member function 'int
StatUtils::mean (std::vector<in t, std::allocator< int> >&, int, int)':
../stddev.cpp:232: warning: converting to 'int' from 'double'
/usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/bits/stl_nu
meric.h:
In function '_Tp std::accumulate (_InputIterator , _InputIterator, _Tp,
_BinaryOperatio n) [with _InputIterator =
__gnu_cxx::__no rmal_iterator<i nt*, std::vector<int , std::allocator< int>
, _Tp = double, _BinaryOperatio n = do_std_dev<int>]':

../stddev.cpp:215: instantiated from here
Here is the code :
template< class T1> class do_std_dev : public binary_function <T1, T1,
T1>
{
public:
do_std_dev(T1 mean): _mean(mean) { }

T1 operator() (T1 initial, T1 element) {
T1 x = element - _mean;
initial = initial + (x * x);
return initial;
}
private:
T1 _mean;
};

int StatUtils::std_ dev( vector<int>& v, int start, int end)
{
int stdDev = 0.0;
int mean2 = mean(v, start, end);
vector<int>::it erator startIter = v.begin();
vector<int>::it erator endIter = v.begin();

startIter += start;
endIter += end;

// this is line 215 of stddev.cpp:
int stdDevSum = accumulate (startIter, endIter, 0.0,
do_std_dev<int> (mean2));

return stdDevSum;
}


Look at the template for accumulate and remember that "0.0" is a double
whereas "0" is an int. What type does accumulate return?

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3069
by: Alexander Bartzas | last post by:
I'm trying to compile route.cpp part of the NetBench Suite (UCLA) and...: > g++ packet.cpp radix.cpp route.cpp -o route There is no problem in the compilation of the code but when I try to run it... Segmentation fault (core dumped) I've located where the problem is... It is part of the following function's
2
7859
by: Happy Li | last post by:
Need help! I have a project with one crystal report. How can I compile it with csc.exe. I have tried the following command line .it compile successfully..but when I run, it display error 'Unable to find the report in the manifest resources'. csc.exe /target:exe /resource:source\abc.rpt,abcsystem.abc.rpt /lib:"C:\Program Files\Common Files\Crystal Decisions\1.1\Managed"...
5
4955
by: TJS | last post by:
trying to display pdf file in browser fails on this line: Response.ContentType = "application/pdf" getting an error about no declaration found for "response" what declaration is needed ???
3
8823
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I don't think I made any changes to either page other than changing the user control that creates the header). Server Error in '/myApp' Application. ---------------------------------------------------------------------------- ----
4
3957
by: Bill Coan | last post by:
NOTE: This was posted earlier to vsnet.vstools.office under a different subject line but received no response. I'm having a problem automating Word's Find object from a .NET application, using late binding. If I use early binding, my code runs fine on most systems, but it is vulnerable to a known bug explained here: http://support.microsoft.com/default.aspx?scid=kb;en-us;292744
10
3710
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server Error in '/QuickStartv20' Application. -------------------------------------------------------------------------------- Configuration Error Description: An error occurred during the processing of a configuration file
1
657
by: ken.carlino | last post by:
Hi, I have the following compile error instantiated from here, I appreciate if someone can help me find out why? g++ -O0 -g3 -Wall -c -fmessage-length=0 -ostddev.o ../stddev.cpp .../stddev.cpp: In member function 'int StatUtils::std_dev(std::vector<int, std::allocator<int> >&, int, int)': .../stddev.cpp:206: warning: converting to 'int' from 'double'
3
2341
by: tony | last post by:
Hello! When I build an exe file that use 6 class library dll I get this error. Could not copy temporary files to the output directory. The file 'MeltPracStorage.dll' cannot be copied to the run directory. Det går inte att komma åt filen eftersom den används av en annan process. All six project is located in the solution that build the exe file This compile error occurred when I add project 'MeltPracStorage to the
6
1770
by: JHNielson | last post by:
This is a very simple question.... I have a form that looks up Records for an unbound drop-down list. It has worked just fine up until last night. Now the button on the form to delete a record doesn't work. i get a "compile error: method or data member not found". The code for the drop-down is this: Private Sub REC_ID_COMBO_AfterUpdate()
0
2027
by: yyuan168a | last post by:
I'm upgrading a VS2003 project to VS2005 but got bunch of C2039 errors in xutility.h file during compiling: :\Program Files\Microsoft Visual Studio 8\VC\include\xutility(610) : error C2039: 'iterator_category' : is not a member of 'ObjectBaseIteratorCL' c:\caps91\interfac\..\interfac\objmgr.h(2070) : see declaration of 'ObjectBaseIteratorCL' C:\Program Files\Microsoft Visual Studio 8\VC\include\xutility(2357) : see reference...
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7378
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.