ورود

View Full Version : مبتدی: سوالاتی در مورد کتاب ++c دایتل



mazmot2000
یک شنبه 27 تیر 1395, 11:20 صبح
با سلام
همانطور که می دانید این کتاب یکی از مراجع مهم در آموزش ++C است . من هم به عنوان یک مبتدی در حال مطالعه آن هستم. و در این مسیر به سوالات و مشگلاتی برخورده ام. مثلا بعضی مطالب فهمش کمی دشوار است و یا بعضی مثال ها به توضیحات بیشتری نیاز دارند. اگر صلاح بدانید این تاپیک را با هدف ارائه توضیحات بیشتر در مورد این کتاب شروع کنیم.
لطفا نظر دهید تا ادامه کار را پیش بگیریم. با تشکر

mazmot2000
یک شنبه 27 تیر 1395, 16:23 عصر
بسیار خوب خودم اولین سوال رو مطرح می کنم.
در فصل سوم این کتاب لازمه که 3 تا برنامه نوشته شده رو با هم لینک کنیم تا اجرا بشه.
من از کامپایلر DEV استفاده می کنم.
برنامه های مورد نظر شماره 11 و 12 و 13 هستند.
اما نمی دونم توی کامپایلرم چطور باید این کارو انجام بدم؟
ممنون میشم راهنمایی بفرمایید.

mirage0411
دوشنبه 28 تیر 1395, 00:16 صبح
من برنامه ها رو در codeblock با کامپایلر GC++ می نویسم مشکلی ندارند و اجرا میشند .
برای لینک کردم هم از include استفاده میشه .

mazmot2000
چهارشنبه 30 تیر 1395, 17:16 عصر
با سلام
ممنون از راهنمائی تون
اما میخوام بدونم توی dev این 3 تا سورس کد رو چطور میشه اجرا کرد؟

mazmot2000
جمعه 01 مرداد 1395, 11:45 صبح
با سلام مجدد
دوستان من کاملا مبتدی هستم و به شکل خودآموز دارم کتاب دایتل رو میخونم
اما در فصل سوم در اجرای مثال های 11 و 12 و 13 که برنامه هایی به هم مرتبط هستند دچار مشکل شدم یعنی نمی دونم چطور این 3 تا کد رو باید در کامپایلر اجرا کرد.
codeblock رو هم امتحان کردم موفق نشدم.



// Fig. 3.11: GradeBook.h
// GradeBook class definition. This file presents GradeBook's public
// interface without revealing the implementations of GradeBook's member
// functions, which are defined in GradeBook.cpp.
#include <string> // class GradeBook uses C++‎ standard string class


// GradeBook class definition
class GradeBook
{
public:
explicit GradeBook( std::string ); // constructor initialize courseName
void setCourseName( std::string ); // sets the course name
std::string getCourseName() const; // gets the course name
void displayMessage() const; // displays a welcome message
private:
std::string courseName; // course name for this GradeBook
}; // end class GradeBook




/************************************************** ************************
* (C) Copyright 1992-2012 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
************************************************** ************************/




// Fig. 3.12: GradeBook.cpp
// GradeBook member-function definitions. This file contains
// implementations of the member functions prototyped in GradeBook.h.
#include <iostream>
#include "GradeBook.h" // include definition of class GradeBook
using namespace std;


// constructor initializes courseName with string supplied as argument
GradeBook::GradeBook( string name )
: courseName( name ) // member initializer to initialize courseName
{
// empty body
} // end GradeBook constructor


// function to set the course name
void GradeBook::setCourseName( string name )
{
courseName = name; // store the course name in the object
} // end function setCourseName


// function to get the course name
string GradeBook::getCourseName() const
{
return courseName; // return object's courseName
} // end function getCourseName


// display a welcome message to the GradeBook user
void GradeBook::displayMessage() const
{
// call getCourseName to get the courseName
cout << "Welcome to the grade book for\n" << getCourseName()
<< "!" << endl;
} // end function displayMessage




/************************************************** ************************
* (C) Copyright 1992-2012 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
************************************************** ************************/






// Fig. 3.13: fig03_13.cpp
// GradeBook class demonstration after separating
// its interface from its implementation.
#include <iostream>
#include "GradeBook.h" // include definition of class GradeBook
using namespace std;


// function main begins program execution
int main()
{
// create two GradeBook objects
GradeBook gradeBook1( "CS101 Introduction to C++‎ Programming" );
GradeBook gradeBook2( "CS102 Data Structures in C++‎" );


// display initial value of courseName for each GradeBook
cout << "gradeBook1 created for course: " << gradeBook1.getCourseName()
<< "\ngradeBook2 created for course: " << gradeBook2.getCourseName()
<< endl;
} // end main






/************************************************** ************************
* (C) Copyright 1992-2012 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
************************************************** ************************/

pe32_64
جمعه 01 مرداد 1395, 14:21 عصر
کدت بدون مشکل در visual studio 2015 (http://barnamenevis.org/showthread.php?527185-%D9%85%D8%B4%DA%A9%D9%84-%D8%AF%D8%B1-%D9%86%D9%88%D8%B4%D8%AA%D9%86-%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%87%D8%A7%DB%8C-c-%D8%AF%D8%B1-visual-studio-2015) کامپایل میشه.

mazmot2000
جمعه 01 مرداد 1395, 19:04 عصر
با تشکر از شما
ولی ممکنه لطفا مختصر بفرمائید این کدها رو چطور اجرا می کنید؟
من visual studio 2012 رو نصب کردم.

ciavosh
جمعه 01 مرداد 1395, 21:05 عصر
کلاً به این صورت هست که باید فایل های c و cpp رو به کامپایلر بدی. وقتی فایل‌های سورس رو به پروژه اضافه میکنی محیط (چه dev چه VS و چه CB) آماده میشه تا زمانی که کامپایل کردی این فایلها رو به کامپایلر بده.

در مورد فایل های هدر (h.) اتفاقی که میافته اینه که کامپایلر وقتی include# رو میبینه دنبال فایلی که جلوش نوشته شده میگرده و وقتی پیداش کرد محتویاتش رو کپی میکنه توی فایلی که داره کامپایل میکنه. فرقی نمیکنه فایل h به پروژه اضافه شده باشه یا نه.

mazmot2000
سه شنبه 18 مهر 1396, 10:49 صبح
با سلام
من نمی دونم چطور توی DEV C++ چطور چند تا برنامه رو باید لینک کنم؟
کسی می تونه راهنمائی کنه؟
الان مشکلم در مورد برنامه برنامه 3-11 کتاب دیتل هست.
خیلی ممنون میشم اگه راهنمائی کنید.