Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!europa.asd.contel.com!gary From: gary@neptune.ctc.contel.com (Gary Bisaga x4219) Newsgroups: comp.lang.c++ Subject: Re: Migrating from FORTRAN to C++ Message-ID: <1991May29.074130@neptune.ctc.contel.com> Date: 29 May 91 11:41:30 GMT References: <91147.181437U10215@uicvm.uic.edu> Sender: news@europa.asd.contel.com (News) Reply-To: gary@ctc.contel.com Organization: Contel Technology Center (until the GTE debacle) Lines: 35 Nntp-Posting-Host: neptune.ctc.contel.com In article <91147.181437U10215@uicvm.uic.edu>, U10215@uicvm.uic.edu writes: > Recently I bought a Borland c++; but I have never programmed in c++. I believe this is a good choice. I too have bought BC++ and both the product and the documentation seem to be quite good. > One thing really bothers me for learning this language. > Is there any way of using FORTRAN COMMON statement in c++? Well ... the "obvious" solution (unless you're not a C programmer) is to use global variables, ones declared outside of any function. I am assuming, however that you want something a little better than variables accessible to ANY function, analogous to FORTRAN's named COMMON. There are at least a few ways of doing this. First, you can use variables declared STATIC. This keeps the variables only accessible to functions in that same source file. This is also an "obvious" C language method. Second, since named COMMON is sort of a data hiding mechanism, you could create a class for each named COMMON you use. Use private member variables for the variables in the named COMMON; make member or friend functions of the functions that use the named commons. Using multiple inheritance could make this more complete -- have classes that multiply inherit where a function needs groups of named COMMONS. Probably the best advice is to try not to do a direct comparison between COMMON and C++ constructs. Acknowledge that COMMON provides a combination data sharing and data hiding mechanism and look to see how C++ does the same two jobs (classes and inheritance). These can be very powerful once you get used to the object oriented "idea." If you want to know more about object-oriented development in general, I highly recommend the book "Object-Oriented Analysis", Second Edition, by Peter Coad. It's part of the Yourdon series, published by Prentice-Hall (ISBN 0-13-629981-4). He and Ed Yourdon also have a forthcoming book about object-oriented design that will probably be good as well. Gary Bisaga (gary@ctc.contel.com)