The CurrCon Java Applet displays prices on this
web page converted with today’s exchange rates into your local international currency,
e.g. Euros, US dollars, Canadian dollars, British Pounds, Indian Rupees…
CurrCon requires an up-to-date browser
and Java version 1.8, preferably 1.8.0_131.
If you can’t see the prices in your local currency,
Troubleshoot. Use Firefox for best results.
C++
The forefather of Java. You can call C++ routines from Java via native method
calls. I learned C++ before Java. Much of my trouble at the beginning came from
presuming they worked the same way just because they look similar.
Learning Java is much
like learning a foreign language. The sooner you start learning to think in the language, rather than think in
your native language (C++) and translating, the better command of the language
you develop. This is even truer of Java than most other computer languages because Java is so strongly idiomatic.
There are canned ways of doing almost everything. You build very little from scratch from the primitive elements.
Java superficially looks a lot like C++, but nearly all my trouble learning
Java came from presuming it should work the same as C++ or
should have buried somewhere some feature I used in C++. It
works quite differently inside and has a completely different design philosophy. The rule of thumb is,
don’t presume Java works the same as C++ just because the syntax looks
the same. Java is a bit like an angler fish that dangles a C++ syntax lure to
seduce C++ programmers into trying Java (for their own good, of course), but it
works at a higher level of abstraction.
The major differences between C++ and Java are:
An array of objects in C++ is a typically a set of structs packed one
right after the other in RAM (Random Access Memory). In Java, it is an array of pointers (aka
references). The pointers each point to an Object
floating independently out there on the heap somewhere.
In Java, the sizes of int, long etc. are rigidly defined in
terms of bits. In C++ they are platform-dependent.
In Java, the JVM (Java Virtual Machine) behaves at if it were big endian, even if internally
it is actually little-endian. In C++, the endianness is platform
dependent.
In Java, the choice of stack of heap allocation is handled automatically by the compiler (Oracle’s
javac is not very bright always using the heap for objects, and the stack for local primitives and references)
and garbage collection of unreferenced objects is automatic. In C++, you have
manual control over where objects are created. The lifetime of objects created on the stack is automatically
controlled, deallocation and destructor automatically called when the method exits; this is known as
deterministic destruction. Whereas you have to manually control the lifetime of dynamic objects allocated with
new by invoking the destructor.
In Java you don’t know for sure that all finalizers will be run; in C++ you do because you invoke the destructors manually. You could write manually invoked
destructors in Java, but they would still not immediately recover the
RAM.
In Java, references are constrained to point only to the beginnings of objects. You cannot do any form of
arithmetic on them. All you can do is compare them for equality. In C++, you
can do arithmetic on pointers and make pointers point anywhere in the address space. In Java, there is only one
way to address an object, via a reference which always points to the start of the object (or more precisely to
the start of the roughly 16 bytes of housekeeping fields preceding an object). In C++ there are many ways to address an object, including directly, via pointer arithmetic
into the middle of the object, via pointer, via address. In Java there is one addressing operator .. In C++, you use . & * ->
[].
In Java, you cannot overload operators. In C++, you can.
In Java, by default methods are virtual (overrideable). In C++, by
default, methods are non-virtual.
Java object code (class files containing JVM
byte codes) will run unmodified on any platform that supports the JVM. C++ object code must be first linked to
produce an executable containing platform-specific machine instructions. It will run only on one platform.
Java checks all subscripts that they are in bounds and all casts for validity. C++ does not.
Java requires a JVM to execute. C++ programs are usually freestanding.
Java does not use a preprocessor. C makes extensive use of a macro preprocessor. C++ tends to use inline functions with less use of the macro preprocessor.
Java does not allow multiple inheritance, though a class may implement several interfaces. C++ supports multiple inheritance.
Java generics are a purely compile time type checking mechanism with type erasure at run time. C++ generics are templates, more like macro expansions of the code for each type.
Java has built-in threads and synchronization. C++ relies on
platform-specific user-written thread libraries.
Java has a vast standard library set, including AWT (Advanced Windowing Toolkit)
and Swing. C++ has a relatively modest standard set of methods and relies on
platform-specific GUI (Graphic User Interface)
libraries.
Java does not let you embed assembler or platform-dependent code. C++
lets you embed machine code assembler and have full access to the native platform API (Application Programming Interface).
In Java, only one type of data can be stored in any variable. In C++, you
can have unions where alternate types of data are stored in the same slot in a struct.
In Java, all classes derive from Object. In C++, classes have no common base.
In Java, all method and field definitions must be inside some class. In C++, you can also define functions and variables independently of classes (and in fact,
you don’t need to define any classes at all to write a C++
program).
Java is defined by Sun. C++ is defined by an ISO (International Standards Organisation)
standard.
Java has the final keyword and C++ has
const. C++ gives you finer control, but that control
can be overridden with a cast.
Using JNI, Java can call C++/C
methods and vice versa.
In C++, your main method’s first
argument is the name of the program that invoked it. In Java that is missing, largely because Java programs can
be invoked in so many way there is usually no executable name that directly invoked it.
In C++ the main method is responsible for
telling the OS (Operating System)
about the error code as its return value. In Java, the main is void. Any method may call System. exit(
retCode ).
That just scratches the surface.
Microsoft C++ Keywords
Microsoft C++ Keywords
Microsoft C++ Keywords
__abstract
__int
__try_cast
delete
goto
property
true
__alignof
__int6
__unaligned
deprecated
if
protected
try
__asm
__int64
__unhook
dllexport
in
public
typedef
__assume
__int8
__uuidof
dllimport
initonly
ref
typeid
__based
__interface
__value
do
inline
register
typename
__box
__leave
__virtual_inheritance
double
int
reinterpret_cast
union
__cdecl
__m64
__w64
dynamic_cast
interface
return
unsigned
__declspec
__m8
__wchar_t
each
interior_ptr
safecast
using
__delegate
__m8d
abstract
else
literal
sealed
uuid
__event
__m8i
array
enum
long
selectany
value
__except
__multiple_inheritance
bool
event
mutable
short
virtual
__fastcall
__nogc
break
explicit
naked
signed
void
__finally
__noop
case
extern
namespace
sizeof
volatile
__finally
__pin
catch
false
new
static
wchar_t
__forceinline
__property
char
finally
noinline
static_cast
while
__gc
__raise
class
float
noreturn
struct
__hook
__sealed
const
for
nothrow
switch
__identifier
__single_inheritance
const_cast
friend
novtable
template
__if_exists
__stdcall
continue
friend_as
nullptr
this
__if_not_exists
__super
default
gcnew
operator
thread
__inline
__try
delegate
generic
private
throw
Microsoft C++ sizeof
The sizes of various data types is
platform dependent in C++, however, here is what they mean when developing for
Microsoft Windows Vista C++.
sizeof various data types is Microsoft C++ for Windows Vista
sizeof various data types is Microsoft C++ for Windows
Vista
C++ Type
Closest
Java Type
Bytes
Bits
Notes
Boolean
Boolean
1
8
1-byte Boolean, defined as unsigned char.
BOOLEAN
Boolean
1
8
1-byte Boolean
byte
byte
1
8
unsigned
BYTE
byte
1
8
unsigned
char
byte
1
8
8-bit signed chars.
unsigned char
byte
1
8
8-bit unsigned chars.
TCHAR
char
2
16
Unicode 16-bit chars. On older systems compiles to 8-bit.
wchar_t
char
2
16
Unicode 16-bit unsigned chars
WCHAR
char
2
16
Unicode 16-bit unsigned chars
short
short
2
16
signed
USHORT
char
2
16
unsigned
int
int
4
32
signed
size_t
int
4
32
unsigned
BOOL
Boolean
4
32
4-byte Boolean
long
int
4
32
signed
DWORD
int
4
32
unsigned
void*
Object
4
32
Pointer/Reference
float
float
4
32
IEEE (Institute of Electrical & Electronics Engineers)
float
long long
long
8
64
signed
double
double
8
64
IEEE
double
See also the table of JNI types. I discovered the
information for the above table by running the following C++ program. You can
modify it to prepare a list of types and sizes for your C/ C++ projects.
C/C++ Header Libraries
To
use a C/C++ method you need include its
prototype in a header file. Here are some of the most common header files and what the roughly contain:
Common C/C++ header files
Common C/C++ header
files
Header
Contents
afx.h
includes Windows API and common C headers
too.
afxcmn.h
MFC (Microsoft Foundation Classes) support for Windows Common Controls
afxdtctl.h
MFC support for Internet
Explorer 4 Common Controls
MS Visual C++ Express 2013 aka Visual is free, but you might ask you to
register and you must use the IE (Internet Explorer)
browser to do it. They ask you a ton of questions. The free version cannot generate 64-bit code, though I have heard you can kludge it by downloading the MS SDK (Software Development Kit)
and running it from the command line. Visual Studio Pro (the cheapest version that can still generate 64-bit)
will set you back
. I found the iso-image version (which includes various other languages)
oddly installed more quickly overall since it does not need to download code during the install. The install does
not adjust the path and do the sets it needs. You can set these manually, or use X:\Program Files (x86)\VC\bin\vcvars32.bat and
X:\Program Files (x86)\VC\bin\x86_amd64\vcvarsx86_amd64.bat to set them up. Make a note of what they did so you can repair
them later if need be.
After you install Visual Studio 12.0, much of it will end up in X:\Program Files (x86)\Common7\
You most commonly want to configure your project as a console application without precompiled headers. When
you use the GUI, the most interesting options are in
right click properties for both the project and source files.
You will normally want to right click Project Properties ⇒ General ⇒ Use of
MFC
⇒ Use MFC in a Static Library
You will normally want to right click Project Properties ⇒ C++ ⇒ Precompiled
Headers ⇒ Not using precompiled headers.
Sometimes it is easier to edit the *.vcxproj files with a text editor. It can be so hard
to find the dialog in the GUI
to control a field.
Right click Project Properties ⇒ C++ ⇒ General and set it to
F:\Program Files (x86)\VC\include; C:\Program Files (x86)\Windows Kits\8.0\Include\shared; C:\Program
Files (x86)\Windows Kits\8.0\include\um; C:\Program Files (x86)\Windows Kits\8.0\include\winrt; E:\Program Files
(x86)\Java\jdk1.8.0\include; E:\Program Files (x86)\Java\jdk1.8.0\include\win32 to ensure
JNI
works.
The command line equivalents to your GUI
options should look something like this for debug:
/FD means incremental rebuild. It is not a real command line option. You can safely
delete compiler intermediate files: *aps *.ilk *.ipch *.ncb *.pbd *.pch. You must keep
the *.sln *.suo *.vcproj *.user.
For command line use, you also need SET environment variables to help the compiler find the include libraries
and the linker find the object libraries. You can set them up with
"J:\Program Files (x86)\VC\Vcvarsall.bat"
for 32 bit use or
"J:\Program Files (x86)\VC\Vcvarsall.bat"amd64 for 64 bit use.
Redistributables
Microsoft Visual C++ needs a run time library called a redistributable package installed on the client
machine. Alternatively, you can create standalone exe files. The built-in Windows
updates are supposed to keep these up to date, but they do not always. Unfortunately, the links below sometimes
serve obsolete files. Keep alert to avoid replacing newer versions with old.
Microsoft Visual
Studio C++ Express 2013 free if you tell them information about yourself.
Use IE to download. Make sure you use the /MT option to statically link, otherwise your clients will need to
install the C++ runtime library. It lets you create 32-bit apps (X:\Program Files (x86)\VC\bin\cl.exe
and 64-bit apps (X:\Program Files\VC\bin\x86_amd64\cl.exe). It includes X:\Program Files (x86)\VC\bin\x86_amd64\ml64.exe, the 64-bit Assembler. I could not get this to work. Every time I tried,
Microsoft redirected me to a rinky-dink web version. So if you have the 2012 version, you are probably best off to
stick with it.
This is the same title as Mark Allen Weiss’s book. Note the direction. ost books presume you know C++ and need to learn Java. This one presumes you know Java and need to learn or brush up on C++ for doing JNI or related work.
Online bookstores carrying C++ For Java Programmers
This is the same title as Timothy A. Budd’s book. Note the direction. Most books presume you know C++ and need to learn Java. This one presumes you know Java and need to learn or brush up on C++ for doing JNI or related work.
Online bookstores carrying C++ For Java Programmers
This is a fascinating book about the birth of a new computer language C++. He talks about the politics, the compromises and the factors that made him design C++ the way it is.
Online bookstores carrying The Design and Evolution of C++
A book for language lawyers on the fine points of C++. It is not suitable for initially learning the language. It is really more aimed at compiler writers. It covers C++ implementation techniques including vtbls.
Online bookstores carrying The Annotated C++ Reference Manual
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy.
Please feel free to link to this page without explicit permission.
Canadian
Mind
Products
IP:[65.110.21.43]
Your face IP:[3.147.205.114]