How do I define a data type that only accepts numbers?

How do I define a data type that only accepts numbers?

I am attempting to create a data type, Point, that takes three numbers for its constructor. Initially, I had writtendata Point = Point Double Double Doublebut I ran into some issues when certain pieces of code expected Ints.So I changed it

Maven - separate integration tests from unit tests

Maven - separate integration tests from unit tests

Is it possible to isolate integration tests from unit tests within same module?I created simple pom: 4.0.0 prj war org.apache.maven.plugins maven-compiler-plugin

maven jacoco: not generating code coverage report

maven jacoco: not generating code coverage report

I am trying to setup jacoco for my project's code coverage My project is based on Java 1.8Here is how things look in my project's pom.xml org.jacoco jacoco-maven-plugin 0.5.10.201208310627 file

How to get a HWND handle out of a System.Windows.Forms.Form

How to get a HWND handle out of a System.Windows.Forms.Form

Given the formSystem.Windows.Forms::Form Form1;and the window handleHWND hWnd;How can I set hWnd to the Handle property of Form1 that does truly exist as a public property that "Gets the window handle that the control is bound to. (Inherite

Static pthreads mutex initialization

Static pthreads mutex initialization

Using pthreads, how would one, in C, initialize a static array of mutexes?For a single static mutex, it seems I can use PTHREAD_MUTEX_INITIALIZER. But what about an static array of them? As, in for example,#include <pthread.h>#define NU

std::vector : cannot bind 'std::ostream {aka std::basic_ostream}' lvalue to 'std::bas

std::vector : cannot bind 'std::ostream {aka std::basic_ostream}' lvalue to 'std::bas

I encountered a confusing error message when trying to do something as simple as std::cout {1,2,3};which says cannot bind 'std::ostream {aka std::basic_ostream}' lvalue to 'std::basic_ostream&&' int main() { std::cout {1,2,3}; }(tested usi

Interface Go with C libraries

Interface Go with C libraries

How does one interface a Go program with a C library?I've been browsing Go's source code but I still didn't figured it out. If someone has already done so, could you share, please?UPDATED: Thanks to @fserb, I am posting some documentation f

Is the comma operator allowed in a constant-expression in C++11?

Is the comma operator allowed in a constant-expression in C++11?

In the process of answering this question on SO for C++11, I realized that in C++03 (as well as in C) the use of the comma operator is explicitly forbidden in a constant-expression.Paragraph 5.19/1 of the C++03 Standard on constant expressi

What does “12345” + 2 do in C?

What does “12345” + 2 do in C?

I've seen this done in C before:#define MY_STRING "12345"...#define SOMETHING (MY_STRING + 2)What does SOMETHING get expanded to, here? Is this even legal? Or do they mean this?:#define SOMETHING (MY_STRING[2]) 1:String literals exist in

Pure virtual functions in C++11

Pure virtual functions in C++11

In C++98, the null pointer was represented by the literal 0 (or in fact any constant expression whose value was zero). In C++11, we prefer nullptr instead. But this doesn't work for pure virtual functions:struct X{ virtual void foo() = n

C++ fastest way to clear or erase a vector

C++ fastest way to clear or erase a vector

I have a code where I routinely fill a vector with between 0 and 5000 elements. I know the maximum never exceeds 5000. Instead of initializing vector multiple times, I would like to do just oncevector myvector;myvector.reserve(5000);However

How can you get the “real” HttpContext within an ASP.NET MVC application?

How can you get the “real” HttpContext within an ASP.NET MVC application?

Unfortunately, I need to do this. I'm using ELMAH for my error log. Before I route to my error.aspx view, I have to grab the default ELMAH error log so I can log the exception. You used to be able to use Elmah.ErrorLog.DefaultHowever, th

Default copy constructor and assignment for class with move constructor and assignment

Default copy constructor and assignment for class with move constructor and assignment

Let's say I have this class:class Test{public: Test();};AFAIK, compiler provides default copy constructor and assignment operators, which assign every member of other instance to the current instance. Now I add move constructor and assig

Osx Lion: Xcode 4.1 how do I setup a c++0x project

Osx Lion: Xcode 4.1 how do I setup a c++0x project

I know there have been other questions like that but (i.e. Can I use C++11 with Xcode?) but mostly related to older versions of Osx or xcode so they don't really seem to be the right solution to go on Osx Lion and xcode 4.1. What are the re

C++11 smart pointers and polymorphism

C++11 smart pointers and polymorphism

I'm rewriting an application using c++11 smart pointers. I have a base class:class A {};And a derived class:class B : public A { public: int b;};I have another class containing a vector with either A or B objects: class C { public: vec

how to see the optimized code in c

how to see the optimized code in c

I can examine the optimization using profiler, size of the executable file and time to take for the execution.I can get the result of the optimization. But I have these questions,How to get the optimized C code.Which algorithm or method use

Visual Studio 2005 vs 2008 - What are the benefits?

Visual Studio 2005 vs 2008 - What are the benefits?

What are the benefits of upgrading from Visual Studio 2005 to 2008?Any thoughts on whether it's worth the jump, or is it better to wait for whatever's coming next? 1:There are tons of improvements. The best part is you can continue to ta

Fluent interface for rendering HTML

Fluent interface for rendering HTML

Rendering HTML with the HtmlTextWriter isn't incredibly intuitive in my opinion, but if you're implementing web controls in web forms it's what you have to work with. I thought that it might be possible to create a fluent interface for this

Ubuntu Eclipse libxml2 error : fatal error: libxml/xmlversion.h: No such file or directory

Ubuntu Eclipse libxml2 error : fatal error: libxml/xmlversion.h: No such file or directory

I want to use libxml2 in my eclipse project. I can use this library on command line by " g++ main.cpp -I/usr/include/libxml2 -lxml2 -o output "But I can't use on eclipse.I add C++ Build->Setting->GCC C Compiler->Includes -I/usr/include/

What is annotation processing in Java?

What is annotation processing in Java?

Quoting, Sun's Official Java Tutorial Class names, 'HelloWorldApp', are only accepted if annotation processing is explicitly requestedWhat does it mean? And how to apply it? 1:"Annotation Processing" is a hook into the compile process

Basic arithmetic operations on int - Java

Basic arithmetic operations on int - Java

I recently noticed an idiosyncrasy of Java regarding basic arithmetic operations in Java. With the following codebyte a = 3;byte b = 4;byte c = a * b;I get a "type mismatch" compilation error...Are basic arithmetic operations in Java (+, -,

cin.ignore(numeric_limits::max(), '\\n'); max() not recognize it

cin.ignore(numeric_limits::max(), '\\n'); max() not recognize it

I'm taking an intro to C++, and I'm using VStudio 2013 on Win7. I try to avoid the wrong data input from my menus, and it's working in all of them except this one. cout > move2; if (move2 size) { cout the only difference is

VS 2008 Professional, Smart Device .NET C# project - slow build

VS 2008 Professional, Smart Device .NET C# project - slow build

I have VS 2008 Professional and a Smart Device .NET C# project. I have ~100 cs files in total. The build takes a very long time, I have to wait for linker approx. 1min (60s) every time I compile the project. I have Core i3, 4GB RAM, 7200rpm

Is there a difference between int& a and int &a?

Is there a difference between int& a and int &a?

This code:int a = 5;int& b = a;b = 7;cout prints out 7, and replacing int& b with int &b also prints out 7.In fact so does int&b and int & b.I tested this kind of behavior with a simple class as well. In general, does it ever matter whether

Is it possible to set affinity with sched_setaffinity in Android?

Is it possible to set affinity with sched_setaffinity in Android?

Is it possible to set CPU affinity in native C code compiled with the Android NDK? Since the system is using a Linux kernel, it should be possible to use the sched_setaffinity/sched_getaffinity functions, but when I compile with the NDK, I