import os
     
    with open('logfile.txt', 'rb') as f:
    f.seek(-2, os.SEEK_END)
    while f.read(1) != b'\n':
    f.seek(-2, os.SEEK_CUR)
    print(f.readline().decode())

출처: https://www.quora.com/How-can-I-read-the-last-line-from-a-log-file-in-Python

'linux' 카테고리의 다른 글

fix invalid argument to attribute "__mode__"" error  (0) 2019.04.17
running valgrind on gentoo  (0) 2019.03.13
vivado execution through rofi  (0) 2019.01.31
ubuntu 설정들  (0) 2019.01.21
xserver error fix after gentoo system upgrade  (0) 2019.01.09

해당 에러는 glibc 2.26~2.27 version과 관련된 문제 같다.

해당 에러를 매뉴얼하게 고치기 위해서는 /usr/include/bits/floatn.h 파일을 조금 수정하면 된다.

 

original code

#if (defined __x86_64__                                                 \
     ? __GNUC_PREREQ (4, 3)                                             \
     : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4)))
# define __HAVE_FLOAT128 1
#else
# define __HAVE_FLOAT128 0
#endif

 

modified code

#if (defined __x86_64__                                                 \
     ? __GNUC_PREREQ (4, 3)                                             \
     : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4)))
//# define __HAVE_FLOAT128 1
//#else
# define __HAVE_FLOAT128 0
#endif

 

'linux' 카테고리의 다른 글

python read file from the bottom  (0) 2019.10.10
running valgrind on gentoo  (0) 2019.03.13
vivado execution through rofi  (0) 2019.01.31
ubuntu 설정들  (0) 2019.01.21
xserver error fix after gentoo system upgrade  (0) 2019.01.09

Here is how I understood not just what virtual functions are, but why they're required:

Let's say you have these two classes:

class Animal { public: void eat() { std::cout << "I'm eating generic food."; } }; class Cat : public Animal { public: void eat() { std::cout << "I'm eating a rat."; } };

In your main function:

Animal *animal = new Animal; Cat *cat = new Cat; animal->eat(); // Outputs: "I'm eating generic food." cat->eat(); // Outputs: "I'm eating a rat."

So far so good, right? Animals eat generic food, cats eat rats, all without virtual.

Let's change it a little now so that eat() is called via an intermediate function (a trivial function just for this example):

// This can go at the top of the main.cpp file void func(Animal *xyz) { xyz->eat(); }

Now our main function is:

Animal *animal = new Animal; Cat *cat = new Cat; func(animal); // Outputs: "I'm eating generic food." func(cat); // Outputs: "I'm eating generic food."

Uh oh... we passed a Cat into func(), but it won't eat rats. Should you overload func() so it takes a Cat*? If you have to derive more animals from Animal they would all need their own func().

The solution is to make eat() from the Animal class a virtual function:

class Animal { public: virtual void eat() { std::cout << "I'm eating generic food."; } }; class Cat : public Animal { public: void eat() { std::cout << "I'm eating a rat."; } };

Main:

func(animal); // Outputs: "I'm eating generic food." func(cat); // Outputs: "I'm eating a rat."

Done.

https://stackoverflow.com/questions/2391679/why-do-we-need-virtual-functions-in-c

 

 

 

 

Why do we need virtual functions in C++?

I'm learning C++ and I'm just getting into virtual functions. From what I've read (in the book and online), virtual functions are functions in the base class that you can override in derived class...

stackoverflow.com

binding 과 관련된 일이다..필요하면 early binding/late binding 찾아봐

https://www.geeksforgeeks.org/virtual-function-cpp/

+ Recent posts